Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace jpeg_decoder with zune-jpeg #1877

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/codecs/jpeg/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub struct JpegDecoder<R> {
orig_color_space: ZuneColorSpace,
width: u16,
height: u16,
icc: Option<Vec<u8>>,
// For API compatibility with the previous jpeg_decoder wrapper.
// Can be removed later, which would be an API break.
phantom: PhantomData<R>,
Expand All @@ -34,13 +33,11 @@ impl<R: Read> JpegDecoder<R> {
// all these functions that only fail if called before decoding the headers
let (width, height) = decoder.dimensions().unwrap();
let orig_color_space = decoder.get_output_colorspace().unwrap();
let icc = decoder.icc_profile();
Ok(JpegDecoder {
input,
orig_color_space,
width,
height,
icc,
phantom: PhantomData,
})
}
Expand Down Expand Up @@ -88,7 +85,12 @@ impl<'a, R: 'a + Read> ImageDecoder<'a> for JpegDecoder<R> {
}

fn icc_profile(&mut self) -> Option<Vec<u8>> {
self.icc.clone()
let mut decoder = zune_jpeg::JpegDecoder::new(&self.input);
if let Ok(_) = decoder.decode_headers() {
decoder.icc_profile()
} else {
None
}
Shnatsel marked this conversation as resolved.
Show resolved Hide resolved
}

fn into_reader(self) -> ImageResult<Self::Reader> {
Expand Down