Incorrect gamma on PNG export
GIMP version: 2.99
Operating System: [all]
Gimp will write wrong gamma information (gAMA chunk) to PNG files for non-sRGB (actually non-2.2-gamma) images.
Code inspection shows that on PNG export Gimp will either write the gamma value found in a "gamma"-parasite or the hard-coded value 2.2 if there is no such parasite. If I understand correctly, that parasite can only come from a PNG-import and does not necessarily match the actual gamma of the image to be exported?
Is the bug reproducible? [Always]
- Open or create any 16-bit linear image
- Export as 16-bit PNG, check option to write gamma. …
Expected result: gAMA chunk in PNG set to gamma value matching the image data
Actual result: PNG set to gamma 0.45455 ( = 1 / 2.2)
I'd love to help with a patch, but I have no idea how to retrieve the actual gamma value from the image.