Skip to content
New issue

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

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

Already on GitHub? # to your account

DuplicateChunk error for image with sRGB chunk preceding gAMA chunk #340

Closed
DutChen18 opened this issue Feb 27, 2022 · 4 comments · Fixed by #341
Closed

DuplicateChunk error for image with sRGB chunk preceding gAMA chunk #340

DutChen18 opened this issue Feb 27, 2022 · 4 comments · Fixed by #341

Comments

@DutChen18
Copy link

This image with an sRGB chunk preceding a gAMA chunk fails to decode in 0.17.4 but it decodes fine in 0.17.3.
https://user-images.githubusercontent.com/6209323/155889742-979e8698-2e87-4206-8930-a1a454c2dc10.png

$ pngcheck raw_strips/006e8720-00d7-425d-9382-7f1676970f5e.png 
ERROR: raw_strips/006e8720-00d7-425d-9382-7f1676970f5e.png
raw_strips/006e8720-00d7-425d-9382-7f1676970f5e.png: Chunk ChunkType { type: gAMA, critical: false, private: false, reserved: false, safecopy: false } must appear at most once.

I believe the breaking change to be from #334

The error originates from this check:

} else if info.source_gamma.is_some() {
return Err(DecodingError::Format(
FormatErrorInner::DuplicateChunk { kind: chunk::gAMA }.into(),
));
} else if info.srgb.is_some() {

Because source_gamma is set in parse_srgb here:
// Set srgb and override source gamma and chromaticities.
info.srgb = Some(rendering_intent);
info.source_gamma = Some(crate::srgb::substitute_gamma());
info.source_chromaticities = Some(crate::srgb::substitute_chromaticities());
Ok(Decoded::Nothing)

@DutChen18 DutChen18 changed the title DuplicateChunk DuplicateChunk error for image with sRGB chunk preceding gAMA chunk Feb 27, 2022
@ogoffart
Copy link

ogoffart commented Mar 1, 2022

I'm also seeing this regression with a bunch of other images.

(For example https://raw.githubusercontent.com/slint-ui/slint/v0.1.6/examples/imagefilter/cat_preview_round.png )

HeroicKatora added a commit to HeroicKatora/image-png that referenced this issue Mar 1, 2022
HeroicKatora added a commit to HeroicKatora/image-png that referenced this issue Mar 1, 2022
@ScranchNew
Copy link

I still encountered this error with version 0.24.8 with this image:

Endless banner

The Error shown was: Decoding(DecodingError { format: Exact(Png), underlying: Some(Format(FormatError { inner: DuplicateChunk { kind: ChunkType { type: iCCP, critical: false, private: false, reserved: false, safecopy: false } } })) }).

Running with version 0.23.14 currently solves the issue.

@fintelia
Copy link
Contributor

@ScranchNew Make sure you run cargo update. If you're still seeing this failure, please open a new issue with both the code you're using and the exact png crate version (0.23.14 and 0.24.8 are versions of the image crate which are compatible multiple png crate versions).

@ogoffart
Copy link

If one can still reproduce this issue with the last png version, the best would be to open the issue directly on the png crate repository and attach the exact image. https://github.com/image-rs/image-png

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants