imagey/src/jxl.rs
electria 59ef65de70
refactor: try to integrate jpegxl_rs with hooks
The problem is, libjxl_rs does not offer a way to get metadata
before decoding the entire image.

As such, there is no reasonable way to implement ImageDecoder here;
I think it's possible to make it decode the image on init,
but that would lead to unexpected behavior performance-wise.
2026-07-29 15:37:51 -07:00

22 lines
655 B
Rust

pub struct JxlDecoder<'a> {
metadata: jpegxl_rs::decode::Metadata,
inner: jpegxl_rs::decode::JxlDecoder<'a, 'a>,
}
impl<'a> image::ImageDecoder for JxlDecoder<'a> {
fn color_type(&self) -> image::ColorType {
image::ColorType::Rgba8
}
fn icc_profile(&mut self) -> image::ImageResult<Option<Vec<u8>>> {
Ok(self.metadata.icc_profile.clone())
}
fn dimensions(&self) -> (u32, u32) {}
fn read_image(self, buf: &mut [u8]) -> image::ImageResult<()>
where
Self: Sized,
{
}
fn read_image_boxed(self: Box<Self>, buf: &mut [u8]) -> image::ImageResult<()> {
self.read_image(buf)
}
}