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

CICP information lost when decoding to png/jpeg #1421

Open
maryla-uc opened this issue Jun 1, 2023 · 6 comments · Fixed by #1422
Open

CICP information lost when decoding to png/jpeg #1421

maryla-uc opened this issue Jun 1, 2023 · 6 comments · Fixed by #1422

Comments

@maryla-uc
Copy link
Collaborator

According to https://github.com/AOMediaCodec/libavif/wiki/CICP if an avif image does not contain an ICC profile, then the first two values of the CICP triplet, i.e. the color primaries and the transfer characteristics should be used to decide how to interpret the RGB values. However, this information is not stored in the decoded png/jpeg and will cause color differences if the values differ from sRGB.

For png it's possible to use the cHRM, gAMA and/or cICP chunks.
For jpeg I'm not aware of a equivalent mechanism, the solution might be to generate an icc profile.

See an example avif image, and the decoded versions with avifdec original.avif decoded.png, at revision c74526f

@wantehchang
Copy link
Collaborator

Maryla: Should we open an issue when we save a decoded AVIF image as JPEG?

@maryla-uc
Copy link
Collaborator Author

H I didn't realize I'd closed it. Reopening it since it was meant to cover both png and jpeg.

@maryla-uc maryla-uc reopened this Jun 7, 2023
@wantehchang
Copy link
Collaborator

I think it's closed by the sentence "Fixes #1421 for png." in #1422.

The commit message of the (squashed) commit of that pull request doesn't have that sentence, so apparently GitHub uses only the first comment in the pull request.

@svgeesus
Copy link

svgeesus commented Mar 5, 2024

For png it's possible to use the cHRM, gAMA and/or cICP chunks.

For PNG it is preferable to just use cICP. That avoids information loss, and covers all of CICP while gAMA can only be used for a simple gamma exponent and not a more complex transfer curve such as PQ, HLG, or even the sRGB curve used by Display P3.

@wantehchang
Copy link
Collaborator

@svgeesus Chris: Could you please review our PNG fix #1422 and see if it is correct? You can post your comments in that pull request. Thanks.

@svgeesus
Copy link

@wantehchang The eventual decisions in that PR (in terms of what to write and when) all look correct to me. Thanks!

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 a pull request may close this issue.

3 participants