Page 1 of 1

Two ICC profiles being read/embedded in an image

Posted: 2013-01-28T14:40:31-07:00
by kjbbb
I have encountered a case where multiple ICC profiles are being embedded into a JPEG, and I don't think this is the correct behavior.

We have a TIFF with two profiles in different sections. It was produced by Adobe PhotoShop CS6. The 8bim header (photoshop:ICCProfile) contains an aRGB 1998 profile blob. The tiff:ICC_PROFILE section (tag 0x8773) also contains an Adobe RGB 1998 profile blob (where it usually is).

ImageMagick seems to be getting confused when this is the case and reading both profiles and concatenating them.

Code: Select all

`convert in.tiff -profile sRGB_IEC61966-2.1.icc out.jpg`

The resultant file has the two profiles "stacked" on top of one another.

The particular sRGB profile we used is 3144 bytes, and the aRGB profile is 560 bytes.

Code: Select all

`identify -verbose out.jpg`

Code: Select all

    Profile-icc: 3704 bytes 
      Description: Adobe RGB (1998) 
      Manufacturer: Adobe RGB (1998) 
      Model: Adobe RGB (1998) 
      Copyright: Copyright 1999 Adobe Systems Incorporated 

As you can see, it's counting the profile length as the two profiles concatenated. The 8bim section is preserved, along with the aRGB blob, and the APP2 section contains the sRGB blob.

Code: Select all

`convert out.jpg profile.icc` 

Upon inspecting the profile that ImageMagick extracts from the file, it is indeed the two concatenated, first appears the Adobe profile, then the sRGB profile.

ImageMagick seems to be getting the colorspaces confused because of this, and is therefore producing the wrong image. Furthermore, if you keep running convert commands with with a -profile option, it will keep concatenating more profiles to this section as long as the photoshop:ICCProfile section is there.

Anyway, this may just be a case of only choosing one profile as the canonical profile section if both photoshop:ICCProfile and the {tiff:ICC_PROFILE, APP2} sections are present.

[*] input tiff: https://dl.dropbox.com/u/20028715/in.tiff
[*] output jpeg: https://dl.dropbox.com/u/20028715/out.jpg
[*] sRGB profile: https://dl.dropbox.com/u/20028715/sRGB.icc
[*] resultant profile: https://dl.dropbox.com/u/20028715/profile.icc

Kevin

Re: Two ICC profiles being read/embedded in an image

Posted: 2013-01-28T15:44:30-07:00
by snibgo
What version of IM are you using? On v6.7.9 and 6.8.1 on Windows 7 the Profile-icc doesn't increase in size, for me.

Re: Two ICC profiles being read/embedded in an image

Posted: 2013-01-28T15:47:04-07:00
by snibgo
I also note that your convert command is wrong. It contains a spurious "sRGB".

Re: Two ICC profiles being read/embedded in an image

Posted: 2013-01-28T15:49:07-07:00
by kjbbb
Darwin Kernel Version 12.1.0 and Linux 2.6.39

ImageMagick 6.7.9 (Linux), 6.8.0 (Darwin), and 6.8.1 (Linux)

Sorry, that was a typo when I made the post. The command was correct when I ran it. I edited the post

Re: Two ICC profiles being read/embedded in an image

Posted: 2013-01-28T16:15:49-07:00
by snibgo
Ah, sorry, I fluffed. Converting to TIFF doesn't concatenate, but converting to JPG does. In fact, it's worse for me than you.

Code: Select all

D:\web\im>rem OP files:

D:\web\im>"c:\program files (x86)\imageMagick-6.7.9-Q16\identify" -verbose in.tiff   | cGrep /p0 /i- /sProfile-icc /o-
    Profile-icc: 560 bytes

D:\web\im>"c:\program files (x86)\imageMagick-6.7.9-Q16\identify" -verbose out.jpg   | cGrep /p0 /i- /sProfile-icc /o-
    Profile-icc: 3704 bytes

D:\web\im>rem snibgo conversion, v6.7.9:

D:\web\im>"c:\program files (x86)\imageMagick-6.7.9-Q16\convert" in.tiff -profile sRGB.icc outSnib.jpg

D:\web\im>"c:\program files (x86)\imageMagick-6.7.9-Q16\identify" -verbose outSnib.jpg | cGrep /p0 /i- /sProfile-icc /o-
    Profile-icc: 61520 bytes

D:\web\im>rem snibgo conversion, v6.8.1:

D:\web\im>"c:\program files (x86)\imageMagick-6.8.1-Q16\convert" in.tiff -profile sRGB.icc outSnib.jpg

D:\web\im>"c:\program files (x86)\imageMagick-6.8.1-Q16\identify" -verbose outSnib.jpg | cGrep /p0 /i- /sProfile-icc /o-
    Profile-icc: 61520 bytes

D:\web\im>rem Repeat the conversions, to tiff

D:\web\im>rem snibgo conversion, v6.7.9:

D:\web\im>"c:\program files (x86)\imageMagick-6.7.9-Q16\convert" in.tiff -profile sRGB.icc outSnib.tiff

D:\web\im>"c:\program files (x86)\imageMagick-6.7.9-Q16\identify" -verbose outSnib.tiff | cGrep /p0 /i- /sProfile-icc /o-
    Profile-icc: 560 bytes

D:\web\im>rem snibgo conversion, v6.8.1:

D:\web\im>"c:\program files (x86)\imageMagick-6.8.1-Q16\convert" in.tiff -profile sRGB.icc outSnib.tiff

D:\web\im>"c:\program files (x86)\imageMagick-6.8.1-Q16\identify" -verbose outSnib.tiff | cGrep /p0 /i- /sProfile-icc /o-
    Profile-icc: 560 bytes