-
Notifications
You must be signed in to change notification settings - Fork 143
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
Add support for parsing the sBIT chunk in the decoder #524
Conversation
@anforowicz Kindly review this PR. |
The following images fail in the
|
|
https://www.w3.org/TR/2003/REC-PNG-20031110/#11IHDR says:
Looking at
I think the failures will go away if |
I am not sure what is going on :-(. FWIW, I tried running |
@anforowicz PTAL, I've made the necessary changes. Just to inform you, I created the file |
It isn't specific to this PR, but we really shouldn't be generating fatal errors in response to corrupt auxiliary chunks. Opened #525 to track.
Why isn't it valid? The spec allows sBIT chunks with indexed color images.
Encoding can be a separate PR. Though I'm not sure sample depth rescaling makes sense in this crate. Might be better to require the user to pass already rescaled data. |
I added a random sBIT chunk value to the original image, specifically 5, 6, and 5 for the R, G, and B channels. The original image wasn’t encoded with rescaled values, so I was wondering if it’s acceptable to have this modified PNG. I’ve been thinking about how other decoders handle this and how the image is rendered by a rendering engine when the sBIT chunk is present. Would a consumer of this decoder rescale the sample depth based on the sBIT value and display the PNG with the rescaled values? If that’s the case, the displayed image could differ from the original pixel values, which led me to believe that the image might be invalid. If I’m mistaken, please correct me.
I looked through the I also referred to documentation about including this in our decoder. The doc mentions that |
sBIT doesn't change how the image looks like at all. sBIT is purely informational hint. |
@kornelski, thanks for the explanation. Regarding the merging of this PR, are there any blocking changes we need to address? |
The indexed test image is 1 MB. We've already got some large images checked into the repository, but it would be better to avoid checking in more. Haven't had a chance to look through the code changes in detail |
@fintelia / @anforowicz PTAL, I've uploaded the updated image for the indexed PNG. |
Thanks @thirumurugan-git! I agree with @fintelia's comment at #524 (comment) that we shouldn't be generating fatal errors in response to corrupt auxiliary chunks. In particular, before this PR Can the PR be tweaked to make Other than the error handling, the PR LGTM. |
Implemented support for sBIT chunk parsing in the decoder.
Issue - #519