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

Document color transformations done by stb_image_write #1737

Open
NogginBops opened this issue Jan 13, 2025 · 2 comments
Open

Document color transformations done by stb_image_write #1737

NogginBops opened this issue Jan 13, 2025 · 2 comments

Comments

@NogginBops
Copy link

When using stb_image_write I have a problem that I do not know if any transformations (sRGB gamut, color space conversions, etc) are being applied to the data I'm saving. I looked in the documentation and I couldn't find any documentation on the intended behavior.

Describe the solution you'd like
I just want some kind of documentation on what, if anything, stb_image_write does to my data. Am I supposed to apply the sRGB gamut myself? Does it specify any colorspace in the file?

Describe alternatives you've considered
An alternative would be to add an API for specifying which transformations you want to apply to your data. While useful this solution would add extra API surface and is probably not worth it.

Additional context
I only really care about what happens when I save to .png so if only that format is documented that's fine with me.

@nothings
Copy link
Owner

nothings commented Jan 13, 2025

For lossless file formats (everything but JPEG), the data is written to the file unaltered, exactly as you passed it in. No tags specifying color profile or gamma are written.

8-bit input data cannot be meaningfully transformed to other 8-bit output data without significant loss (a variant on the pigeonhole principle). The lack of transformation is not documented because no such transformation would ever make sense, since it would be so lossy.

@NogginBops
Copy link
Author

Does it hurt to add a statement in the documentation that explicitly states that no transformation on the data is done? It was not obvious to me that no such transformations would be applied, so I went looking in the documentation and didn't find anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants