Page 1 of 1

Color profile stripped when writing png

Posted: 2019-11-01T13:06:55-07:00
by ikerr
I am trying to run the following command on a png file with an embedded sRGB profile:

Code: Select all

convert in.png -profile AdobeRGB1998.icc -strip -profile AdobeRGB1998.icc out.png
Note: the actual command that I am using is more complex, but I have reduced it to the above for the purpose of discussion.

The idea is to first convert to the AdobeRGB1998.icc profile and then strip comments from the file. However, since "-strip" also strips color profiles, there is an additional "-profile AdobeRGB1998.icc" option after the "-strip" to re-add the profile.

ImageMagick Version: ImageMagick 7.0.9-2 Q16 x86_64 2019-10-31
OS: macOS 10.13.6
Expected output: out.png should contain an AdobeRGB1998.icc profile
Actual output: out.png does not contain an ICC profile

The result is that the colors in the image are relative to the AdobeRGB1998 profile, but the profile is not embedded in the image, which leads to incorrect colors when the image is displayed. This seems like a bug.

This problem does not occur if I write to a jpg:

Code: Select all

convert in.png -profile AdobeRGB1998.icc -strip -profile AdobeRGB1998.icc out.jpg
I can also work around the problem using a two-step process:

Code: Select all

convert in.png -profile AdobeRGB1998.icc -strip tmp.png
convert tmp.png -profile AdobeRGB1998.icc out.png
The images mentioned in this post can be found here: https://gist.github.com/ikerr/0cc125c8b ... a7df0f8922

Re: Color profile stripped when writing png

Posted: 2019-11-01T13:58:10-07:00
by snibgo
Your link seems to be broken: "We can’t connect to the server at git.dev.box.net."

However, I confirm the problem on IM v7.0.8-64. Your second "-profile" should assign that ICC profile, which should be embedded in the resulting PNG file, but it isn't.

Saving to a TIFF seems to work, as well as JPG (as you say). Hence it seems to be a bug isolated to writing PNG files.

Re: Color profile stripped when writing png

Posted: 2019-11-04T11:29:49-07:00
by ikerr
Thanks @snibgo, I updated the link in my original post and also file an issue here: https://github.com/ImageMagick/ImageMagick/issues/1774