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

Add support for the sRGB chunk. #260

Merged
merged 1 commit into from
Dec 7, 2020
Merged

Conversation

de-vri-es
Copy link
Contributor

@de-vri-es de-vri-es commented Nov 29, 2020

This PR adds support for the sRGB chunk.

A new type SrgbRenderingIntent is added, and Info now has a srgb: Option<SrgbRenderingIntent> field.

If the decoder encounters an sRGB chunk, it sets the srgb field along with the source_gamma and source_chromaticities field (using predefined values). Any future gAMA or cHRM chunks are ignored (and the data from previous ones is overwritten).

The encoder adds the sRGB chunk along with the pre-defined gAMA and cHRM chunks if the srgb field is set. Manually defined source_gamma and source_chromaticities are ignored in this case.

I believe this conforms to the specification: https://www.w3.org/TR/2003/REC-PNG-20031110/#11sRGB

/edit: CI failure looks like the same Windows/rustup issue, unrelated to the PR contents :(

@de-vri-es
Copy link
Contributor Author

de-vri-es commented Nov 29, 2020

Note: Maybe SrgbRenderingIntent should be renamed to IccRenderingIntent or just RenderingIntent, as it is more general than its use in the sRGB chunk. It doesn't appear in other places in the PNG specification though.

@HeroicKatora
Copy link
Member

CI failure was addressed in #261.

@de-vri-es
Copy link
Contributor Author

Rebased, CI now passes :)

@HeroicKatora HeroicKatora merged commit 22a924b into image-rs:master Dec 7, 2020
@HeroicKatora
Copy link
Member

Thanks!

@de-vri-es
Copy link
Contributor Author

Thanks for the review :)

@de-vri-es de-vri-es deleted the srgb branch December 7, 2020 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants