PSDs retain previous profile in file

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
iceman
Posts: 4
Joined: 2010-07-07T12:02:28-07:00
Authentication code: 8675308

PSDs retain previous profile in file

Post by iceman »

Darwin Kernel Version 10.4.0
ImageMagick 6.6.3-0 2010-07-06 Q16

I use a lot of custom CMYK profiles that are a few megabytes in size due to large lookup tables. Converting the TIF and PSD below both yield a valid sRGB embedded jpeg file. But the jpeg from the PSD weighs in at over 3MB, about the size of the profile. If I further run a convert -strip -profile 'sRGB_IEC61966-2-1_black_scaled.icc' command, then the jpeg is the proper size and correct. Seems like past profiles are not always removed correctly. Or is this behavior intended?

tiftest.tif TIFF 6990x8620 6990x8620+0+0 8-bit DirectClass 244.5MB 0.030u 0:00.029
  • Creator Tool : Adobe Photoshop CS3 Macintosh
    Profile Description : X_GRACoL_2008.icc
    ICC Profile Name : X_GRACoL_2008.icc
convert -profile 'X_GRACoL_2008.icc' -profile 'sRGB_IEC61966-2-1_black_scaled.icc' -alpha off 'tiftest.tif'[0] -resize '2000x2000>' tiftest.jpg

tiftest.jpg JPEG 1258x1551 1258x1551+0+0 8-bit DirectClass 261KB 0.000u 0:00.000
  • Creator Tool : Adobe Photoshop CS3 Macintosh
    Profile Description : sRGB IEC61966-2-1 black scaled
    ICC Profile Name : X_GRACoL_2008.icc
psdtest.psd PSD 6990x8620 6990x8620+0+0 8-bit DirectClass 279.6MB 0.160u 0:00.100
  • Creator Tool : Adobe Photoshop CS3 Macintosh
    Profile Description : X_GRACoL_2008.icc
    ICC Profile Name : X_GRACoL_2008.icc
convert -profile 'X_GRACoL_2008.icc' -profile 'sRGB_IEC61966-2-1_black_scaled.icc' -alpha off 'psdtest.psd'[0] -resize '2000x2000>' psdtest.jpg

psdtest.jpg JPEG 1258x1551 1258x1551+0+0 8-bit DirectClass 3.721MB 0.030u 0:00.029
  • Creator Tool : Adobe Photoshop CS3 Macintosh
    Profile Description : sRGB IEC61966-2-1 black scaled
    ICC Profile Name : X_GRACoL_2008.icc

-strip
psdclear.jpg JPEG 1258x1551 1258x1551+0+0 8-bit DirectClass 197KB 0.000u 0:00.000
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PSDs retain previous profile in file

Post by snibgo »

If in.tif has a profile, any profile, which you want to convert it to XYZ.icc:

convert in.tif -profile XYZ.icc out.jpg

Note the "-profile" and other commands go between the file names, and I don't tell IM the existing profile of in.tif.
snibgo's IM pages: im.snibgo.com
iceman
Posts: 4
Joined: 2010-07-07T12:02:28-07:00
Authentication code: 8675308

Re: PSDs retain previous profile in file

Post by iceman »

The result is the same with that syntax.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PSDs retain previous profile in file

Post by snibgo »

Can you post a sample?
snibgo's IM pages: im.snibgo.com
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: PSDs retain previous profile in file

Post by Drarakel »

You can recreate that behaviour if you use profiles. Example:

Code: Select all

convert rose: -profile "sRGB IEC61966-2.1.icc" psd:- | convert - -profile "U.S. Web Coated (SWOP) v2.icc" rosetest.jpg
That should convert the RGB image to CMYK and embed the CMYK profile. The conversion is successful, but with PSD as input, the embedding of the profiles can get.. strange:
identify -verbose rosetest.jpg
...
Profiles:
Profile-8bim: 3184 bytes
Profile-icc: 560312 bytes
Description: sRGB IEC61966-2.1
Manufacturer: IEC http://www.iec.ch
Model: IEC 61966-2.1 Default RGB colour space - sRGB
Copyright: Copyright (c) 1998 Hewlett-Packard Company

...
The result in this special CMYK file: 'Profile-8bim' has the sRGB color profile (the sRGB profile itself has 3.144 Bytes) , and 'Profile-icc' shows a mix of two profiles (the above used CMYK profile itself has 557.168 Bytes).

There was a similar case in this thread:
viewtopic.php?f=1&t=16109

One part of the problem is the color profile detection within PSD.
convert rose: -profile "sRGB IEC61966-2.1.icc" rose.psd
identify -verbose rose.psd
...
Profiles:
Profile-8bim: 3184 bytes
Profile-icc: 3144 bytes
Description: sRGB IEC61966-2.1
Manufacturer: IEC http://www.iec.ch
Model: IEC 61966-2.1 Default RGB colour space - sRGB
Copyright: Copyright (c) 1998 Hewlett-Packard Company
...
It's only one color profile that is stored within the PSD file, but ImageMagick shows it also as Photoshop profile. When a color conversion with profiles is done, the input 'Profile-icc' doesn't get embedded in the output file. So far, so good. But the 'Profile-8bim' gets transferred to the output file. So, usually, with such a conversion - with PSD as input - the ICC profile shows the destination color profile, and the 8bim profile has the source color profile in the final output.
And, as in my rosetest example, in some cases the ICC profile shows even a mix (but it's not yet stored as that!). Now, if I store the color profile with "convert rosetest.jpg ICC:rose-profile.icc", I get a 560KB sRGB profile. :)

As workaround, one has to strip the Photoshop profile at least:

Code: Select all

convert rose: -profile "sRGB IEC61966-2.1.icc" psd:- | convert - +profile "8bim" -profile "U.S. Web Coated (SWOP) v2.icc" rosetest2.jpg
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: PSDs retain previous profile in file

Post by snibgo »

This appears to be a bug that is specific to reading PSD files. (Windows 7, IM 6.6.2-4.)

The following works as I would expect:

Code: Select all

convert rose: -profile sRGB.icm r1.jpg
convert r1.jpg -profile US_Sheetfed_Coated_v2.icm r2.jpg

identify -verbose r1.jpg

  Profiles:
    Profile-icc: 3144 bytes
      Description: sRGB IEC61966-2.1
      Manufacturer: IEC http://www.iec.ch
      Model: IEC 61966-2.1 Default RGB colour space - sRGB
      Copyright: Copyright (c) 1998 Hewlett-Packard Company

identify -verbose r2.jpg

  Profiles:
    Profile-icc: 557168 bytes
      Description: U.S. Sheetfed Coated v2
      Manufacturer: U.S. Sheetfed Coated v2
      Model: U.S. Sheetfed Coated v2
      Copyright: Copyright 2000 Adobe Systems, Inc.
But when the intermediate file is PSD format:

Code: Select all

convert rose: -profile sRGB.icm r1.psd
convert r1.psd -profile US_Sheetfed_Coated_v2.icm r2b.jpg

identify -verbose r1.psd

  Profiles:
    Profile-8bim: 3184 bytes
    Profile-icc: 3144 bytes
      Description: sRGB IEC61966-2.1
      Manufacturer: IEC http://www.iec.ch
      Model: IEC 61966-2.1 Default RGB colour space - sRGB
      Copyright: Copyright (c) 1998 Hewlett-Packard Company

identify -verbose r2b.jpg

  Profiles:
    Profile-8bim: 3184 bytes
    Profile-icc: 560312 bytes
      Description: sRGB IEC61966-2.1
      Manufacturer: IEC http://www.iec.ch
      Model: IEC 61966-2.1 Default RGB colour space - sRGB
      Copyright: Copyright (c) 1998 Hewlett-Packard Company
I note the size of the ICC profile in r2b.jpg is 560312, which equals 557168 plus 3144.

I would expect the ICC profile of r2b.jpg to be identical to that of r2.jpg.

I think this is consistent with Drarekel's report.
snibgo's IM pages: im.snibgo.com
iceman
Posts: 4
Joined: 2010-07-07T12:02:28-07:00
Authentication code: 8675308

Re: PSDs retain previous profile in file

Post by iceman »

Thanks. +profile "8bim" is an excellent solution to the problem for the time being.
Post Reply