Color profile stripped when writing png

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
ikerr
Posts: 3
Joined: 2019-08-01T11:07:42-07:00
Authentication code: 1152

Color profile stripped when writing png

Post by ikerr » 2019-11-01T13:06:55-07:00

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
Last edited by ikerr on 2019-11-04T11:01:22-07:00, edited 2 times in total.

snibgo
Posts: 12299
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Color profile stripped when writing png

Post by snibgo » 2019-11-01T13:58:10-07:00

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.
snibgo's IM pages: im.snibgo.com

ikerr
Posts: 3
Joined: 2019-08-01T11:07:42-07:00
Authentication code: 1152

Re: Color profile stripped when writing png

Post by ikerr » 2019-11-04T11:29:49-07:00

Thanks @snibgo, I updated the link in my original post and also file an issue here: https://github.com/ImageMagick/ImageMagick/issues/1774

Post Reply