PDF CMYK to TIF with profiles not preserving colors correctly

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
eatme
Posts: 2
Joined: 2019-11-08T06:39:48-07:00
Authentication code: 1152

PDF CMYK to TIF with profiles not preserving colors correctly

Post by eatme » 2019-11-08T08:59:49-07:00

Hello.

I need help. It's been several days I'm having troubles with this. Usually i don't post in forums , but it appears that I'm doing something wrong and I can't figure this out why it's happening. I'd be really grateful if someone can help me with this.

Ok.. I have a source PDF file made in Adobe Illustrator then exported in 3 versions. The working file is in CMYK color mode and I have assigned a color profile. Then I'm exporting it to 3 different source versions :
-colors according to the profile but profile not embeded in the pdf http://demo.d-alex.me/print/src_no_profile.pdf
-pdf in pdfx format with embeded profilehttp://demo.d-alex.me/print/src_profile_pdfx.pdf
-pdf print quality with embeded profilehttp://demo.d-alex.me/print/src_profile.pdf

All of them are orrectly exported, because when opening in photoshop : Image

i get the exact color value for the background ( gray: was #262626 , smyk values are ok ) as it is in illustratorImage

Then i exported one tiff with the same color profile from illustrator. Photoshop recognizes perfectly the color profile and also the colors are perfect.
So far so good. That's exactly what I need http://demo.d-alex.me/print/export_perfect.tif
, but done through the command line with imagemagick or Imagick...

Then I'm extracting all the embeded profiles from the perfectly exported and recognized by PS tiff file and save them as .icc, .8bim , .xmp. One thing I'm missing here is there are 2 additional profiles( tiff and psd:additional-info ) , which I cannot extract:
http://demo.d-alex.me/print/col-0.icc
http://demo.d-alex.me/print/col-0.xmp
http://demo.d-alex.me/print/col-0.8bim
http://demo.d-alex.me/print/col-1.icc
http://demo.d-alex.me/print/col-1.xmp
http://demo.d-alex.me/print/col-1.bim
And also the official icc. http://demo.d-alex.me/print/JapanColor2011Coated.icc

Then .. whatever I try to convert from the cmyk pdf's to cmyk tif it results in twisted colors. The gray background becomes either a negative or instead of gray it turns brownish. The negative is also not properly colored because if i invert it it's even worse.

These are the following commands that I used.

Converting the no profile source with targeted color profiles:

Code: Select all

convert -verbose -colorspace CMYK -profile col-src.xmp src_no_profile.pdf -profile JapanColor2011Coated.icc -profile col-0.icc -profile col-1.icc -profile col-0.8bim -profile col-1.8bim -profile col-0.xmp -profile col-1.xmp -compress lzw -depth 8 res_no_profile.tif
Result: http://demo.d-alex.me/print/res_no_profile.tif and output:

Code: Select all

'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pamcmyk32' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -dUseCIEColor  '-sOutputFile=/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-76538pB5sBw3MvoPc%d' '-f/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-76538r7tcxb7WKLos' '-f/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-76538e6fh3jqbR8Ne'
/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-76538pB5sBw3MvoPc1 PAM 1966x800 1966x800+0+0 8-bit ColorSeparation CMYK 5.99985MiB 0.030u 0:00.023
src_no_profile.pdf AI 1966x800 1966x800+0+0 16-bit ColorSeparation CMYK 5.99985MiB 0.000u 0:00.001
col-src.xmp XMP 1x1 1x1+0+0 16-bit sRGB 17055B 0.000u 0:00.000
JapanColor2011Coated.icc ICC 1x1 1x1+0+0 16-bit sRGB 1.88761MiB 0.000u 0:00.005
col-0.icc ICC 1x1 1x1+0+0 16-bit sRGB 557168B 0.000u 0:00.001
col-1.icc ICC 1x1 1x1+0+0 16-bit sRGB 557168B 0.010u 0:00.000
col-0.8bim 8BIM 1x1 1x1+0+0 16-bit sRGB 4890B 0.000u 0:00.000
col-1.8bim 8BIM 1x1 1x1+0+0 16-bit sRGB 4890B 0.000u 0:00.000
col-0.xmp XMP 1x1 1x1+0+0 16-bit sRGB 17531B 0.000u 0:00.000
col-1.xmp XMP 1x1 1x1+0+0 16-bit sRGB 17531B 0.000u 0:00.000
src_no_profile.pdf=>res_no_profile.tif AI 1966x800 1966x800+0+0 8-bit CMYK 604449B 1.480u 0:00.227
Converting the embeded profile pdfx version:

Code: Select all

convert -verbose -colorspace CMYK src_profile_pdfx.pdf -profile JapanColor2011Coated.icc -profile col-0.icc -profile col-1.icc -profile col-0.8bim -profile col-1.8bim -profile col-0.xmp -profile col-1.xmp -compress lzw -depth 8 res_profile_pdfx.tif
Result: http://demo.d-alex.me/print/res_profile_pdfx.tif and output:

Code: Select all

'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pamcmyk32' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -dUseCIEColor  '-sOutputFile=/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-765473y1FMSCX8Dpi%d' '-f/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-76547bvXafAvVDez2' '-f/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-76547utxjUI29E08t'
/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-765473y1FMSCX8Dpi1 PAM 1966x800 1966x800+0+0 8-bit ColorSeparation CMYK 5.99985MiB 0.030u 0:00.023
src_profile_pdfx.pdf AI 1966x800 1966x800+0+0 16-bit ColorSeparation CMYK 5.99985MiB 0.000u 0:00.001
JapanColor2011Coated.icc ICC 1x1 1x1+0+0 16-bit sRGB 1.88761MiB 0.000u 0:00.006
col-0.icc ICC 1x1 1x1+0+0 16-bit sRGB 557168B 0.010u 0:00.001
col-1.icc ICC 1x1 1x1+0+0 16-bit sRGB 557168B 0.020u 0:00.000
col-0.8bim 8BIM 1x1 1x1+0+0 16-bit sRGB 4890B 0.000u 0:00.000
col-1.8bim 8BIM 1x1 1x1+0+0 16-bit sRGB 4890B 0.000u 0:00.000
col-0.xmp XMP 1x1 1x1+0+0 16-bit sRGB 17531B 0.000u 0:00.000
col-1.xmp XMP 1x1 1x1+0+0 16-bit sRGB 17531B 0.000u 0:00.000
src_profile_pdfx.pdf=>res_profile_pdfx.tif AI 1966x800 1966x800+0+0 8-bit CMYK 604449B 1.450u 0:00.218
Converting the print print press quality with completely embeded profile:

Code: Select all

convert -verbose -colorspace CMYK src_profile.pdf -profile col-0.icc -profile col-1.icc -profile col-0.8bim -profile col-1.8bim -profile col-0.xmp -profile col-1.xmp -compress lzw -depth 8 res_profile.tif
Result: http://demo.d-alex.me/print/res_profile_pdfx.tif and output:

Code: Select all

'gs' -sstdout=%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 '-sDEVICE=pamcmyk32' -dTextAlphaBits=4 -dGraphicsAlphaBits=4 '-r72x72' -dUseCIEColor  '-sOutputFile=/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-76556QeKaDnfP9BVQ%d' '-f/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-76556Cy2RWYdYElF4' '-f/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-76556YuopUmXolD8c'
/var/folders/0t/sf8ccbhn2l3dxb7n87qfkhg00000gn/T/magick-76556QeKaDnfP9BVQ1 PAM 1966x800 1966x800+0+0 8-bit ColorSeparation CMYK 5.99985MiB 0.030u 0:00.026
src_profile.pdf AI 1966x800 1966x800+0+0 16-bit ColorSeparation CMYK 5.99985MiB 0.000u 0:00.001
col-0.icc ICC 1x1 1x1+0+0 16-bit sRGB 557168B 0.010u 0:00.001
col-1.icc ICC 1x1 1x1+0+0 16-bit sRGB 557168B 0.000u 0:00.000
col-0.8bim 8BIM 1x1 1x1+0+0 16-bit sRGB 4890B 0.000u 0:00.000
col-1.8bim 8BIM 1x1 1x1+0+0 16-bit sRGB 4890B 0.000u 0:00.000
col-0.xmp XMP 1x1 1x1+0+0 16-bit sRGB 17531B 0.000u 0:00.000
col-1.xmp XMP 1x1 1x1+0+0 16-bit sRGB 17531B 0.000u 0:00.000
src_profile.pdf=>res_profile.tif AI 1966x800 1966x800+0+0 8-bit CMYK 604159B 0.370u 0:00.067
I have noticed three things though... when doing identify only the no profile source pdf version shows as colorspace: CMYK , the other ones show as sRBG. Illustrator and photoshop recognize all of them correctly as cmyk , color values and profiles are preserved.
I had to put -colorspace CMYK before each of the source otherwise it goes negative or bananas. Also tried to use the extracted .xmp profile from the profile pdf and prepend it in the before source parameter to0 prevent color conversion, but same results. So problem 1 is I guess imagemagick thinks the source is sRGB, then convert to cmyk which twists the colors then convert to tif and embed profiles which may twist even more the colors. I can tweak the exif tags of the source files, but not sure which tag is reflecting the DirectClass property in identify.

Problem 2 is as you see from the verbose output :

Code: Select all

col-0.icc ICC 1x1 1x1+0+0 16-bit sRGB 557168B 0.010u 0:00.001
col-1.icc ICC 1x1 1x1+0+0 16-bit sRGB 557168B 0.000u 0:00.000
It thinks the .icc profiles are sRBG , rather than CMYK which they should be. Even the official profile is recognized as sRGB

Problem 3 is : Looking at the ghostscript command it uses an sDEVICE=pamcmyk32 rather than tiff24nc or tiff32nc and I can't seem to find an argument to switch the ghostscript device. Btw this is on my osx machine. On my ubunt linux server the same command produces pngalpha driver.

If anyone has any idea what I'm doing wrong please share. It's been 3 days non-stop retrying various scenarios.
Any advice will be highly appreciated.

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

Re: PDF CMYK to TIF with profiles not preserving colors correctly

Post by snibgo » 2019-11-08T12:14:23-07:00

What version of IM? What version of Ghostscript? I use IM v7.0.8-64 and Ghostscript v9.19.

src_profile.pdf contains the name of a profile:

Code: Select all

<photoshop:ICCProfile>Japan Color 2001 Coated</photoshop:ICCProfile>
But the profile itself does not seem to be included.

IM will ignore this profile name; it can't do anything with it. As far as I know, Ghostscript will also ignore it.

If you want to rasterize it with IM (using Ghostscript), I suggest you:

Code: Select all

magick -colorpace CMYK src_profile.pdf -profile JapanColor2001Coated.icc out.tiff
I don't know the difference between the 2001 and 2011 versions.

This creates CMYK pixels, which you can convert to sRGB or anything else if you want by using another "-profile" operation.


Problem 1:

Code: Select all

magick -verbose -colorspace sRGB src_profile.pdf out.tiff
out.tiff is then a sRGB file, that looks the same colours as Adobe Acrobat Reader shows for src_profile.pdf.

Problem 2: Ignore the verbose output about the *.icc files. That output is for images (note the "1x1", as if an ICC file has a pixel).

Problem 3: If you prefix the PDF input with "-colorspace sRGB" or "-colorspace CMYK", this will change the "sDEVICE=" option. I don't think IM can generate a "sDEVICE=tiff*" option.
snibgo's IM pages: im.snibgo.com

eatme
Posts: 2
Joined: 2019-11-08T06:39:48-07:00
Authentication code: 1152

Re: PDF CMYK to TIF with profiles not preserving colors correctly

Post by eatme » 2019-11-08T18:12:30-07:00

Hey snibgo. Thanks for the reply.

I use ImageMagick 7.0.9-2 (latest) and Ghostscript 9.50 (2019-10-15).

The profile should be included. At least it's recognized by the importing software( and also the file size between no_profile and profile.pdf si huge ). My mistake about the profile 2011 . it should be 2001. Didn't see it properly , however .. sRGB is not useful to me , since it should go to print. I was just wondering if there was a better (or best way ) to convert an exported PDF in CMYK with a profile to a tiff with the same profile again in cmyk and have absolutely the same values for the colors. I also extracted the .icc profiles from a working tif and used them during the conversion,but still the colors were not ok in the resulting tiff . But I guess this is a specific case. Thanks anyway for digging into this and helping me. I might have a workaround for now that will do the job for me.

Post Reply