ImageMagick6 icon indicating copy to clipboard operation
ImageMagick6 copied to clipboard

icc profile in png ignored

Open josch opened this issue 4 years ago • 2 comments

Hi,

I'm on Debian unstable with imagemagick 6.9.11-60.

Lets use this PNG image as an example: normal

Then I attach an ICC profile which switches the color channels around to produce this:

icc

I cannot attach the icc profile, so here is its gizipped and base64 encoded version:

H4sIAJjkbmAAA2NgYLzCAAW5eSVFQe5OChGRUQoMSCAxubiAAS/4do2BEURf1sWvDivgTEktTgbS
H4A4vrykoISBgTEAyBYpAjoEyE4BsdMh7AoQOwnC7gGrCQlyBrIXANkC6UjsJCR2ckERyMwNQLYi
1C4QYE1LzE4lw714ASLsPhuDw4RRnAshpnydgYE/hoFh62GEWMESBgaLIAYG5mkIsWSguh1AMclZ
yaVFZVCjmRgY/v8vSa0oAXHy8hWS8wsqizLTM0p0FEqLUxXSilJTcypB/gEAnCqXJNQBAAA=

As you might already see while viewing above images in your browser, the original image differs from the one with the attached icc profile and has the color channels swapped as expected. I observe this effect with firefox as well as with chromium.

But when you download them and use display on the image with the channel swapping icc profile embedded, you will see that the color channels do not get swapped at all and it looks like the original png. If you use compare, imagemagick will report:

compare -metric AE normal.png icc.png null:
0

If I open the second image with gimp, then the color channels are correctly swapped.

Why does imagemagick ignore the icc profile while firefox, chromium and gimp do not?

josch avatar Apr 08 '21 11:04 josch

The display utility displays raw pixels. If you want to transform the raw pixels you must explicitly specify the color transformation. Your image has an embedded profile but no destination profile is set. Simply specify it and you get desired results:

display -profile sRGB.icc normal.png

urban-warrior avatar Apr 10 '21 16:04 urban-warrior

Okay, I indeed did not know that display was only meant to display raw pixel values.

By the same logic, the compare tool probably also is meant to only compare raw pixel values and ignore color profiles?

What I do find odd is, that if I run compare with -profile sRGB.icc, then I do get the result I expected:

compare -profile /usr/share/color/icc/sRGB.icc -metric AE normal.png icc.png null:
2872

I must admit that I probably never wanted to use the compare tool to compare the raw pixel values but was only ever interested in the color information that would end up on my screen if I would open both images side-by-side. But this is probably by design and documented somewhere? I cannot find the information that would've prevented me from opening this issue at https://legacy.imagemagick.org/script/command-line-options.php#profile

Can you confirm that with that use-case in mind I should really always run compare -profile /usr/share/color/icc/sRGB.icc instead of just running compare?

Thank you!

josch avatar Apr 11 '21 05:04 josch