Page 1 of 1

TIFF conversion RGB->CMYK 'the right way'

Posted: 2009-11-30T02:15:56-07:00
by rshea
Hi - I have a RGB TIF which I want to convert to use CMYK. Everything appears to work well but the Python Imaging Library (PIL) chokes on the output. Before I dig too far into PIL I'd like to be sure I'm doing the right thing when making the conversion from an ImageMagick point of view.

I do two different steps to convert the TIF from RGB to CMYK. In step1 I provide a CMYK profile to swop for the RGB one. In Step2 I flatten the TIF and then use TIFFSET to explicitly set some headers which are otherwise missing.

What I'd be grateful to know is from an Imagemagick point of view does it seem I'm doing 'the right thing' ? Or is there something obviously wrong which would upset most right thinking TIF readers !


STEP 1 (in windows .BAT form)
==========================

Code: Select all

@echo off
set ICCCOLPROFDIR=C:\Adobe_ICC_Profiles_bundler
set IMGINPUTDIR=C:\20091130
set IMGOUTPUTDIR=C:\20091130\OutputImages
set CONVERTEXE=C:\ImageMagick\convert.exe
@echo off
REM Convert the TIFF Produced directly from the ZendGraph output
set INPUTFILE=ZENDGraphOutput.TIFF
set OUTPUTFILE=ZENDGraphOutput-Step1.TIF
@echo on 
%CONVERTEXE% %IMGINPUTDIR%\%INPUTFILE% +profile icc -profile %ICCCOLPROFDIR%\RGBProfiles\AdobeRGB1998.icc -profile %ICCCOLPROFDIR%\CMYKProfiles\USWebCoatedSWOP.icc -strip  %IMGOUTPUTDIR%\%OUTPUTFILE%
@echo off
STEP 2
========

Code: Select all

@echo off
set CONVERTEXE=C:\ImageMagick\convert.exe
set IMGDIR=C:\20091130\OutputImages
set TIFFSETEXE=C:\bin\installed\GnuWin32\bin\tiffset.exe
@echo off
REM Convert the TIFF Produced directly from the ZendGraph output
set INPUTFILE=ZENDGraphOutput-Step1.TIF
set INTERMEDIATEFILE=ZENDGraphOutput-Step2.TIF
@echo on 
%CONVERTEXE%  %IMGDIR%\%INPUTFILE%  -flatten +matte %IMGDIR%\%INTERMEDIATEFILE%
@echo off
%TIFFSETEXE% -s 305 Banana %IMGDIR%\%INTERMEDIATEFILE%
%TIFFSETEXE% -s 296 2   %IMGDIR%\%INTERMEDIATEFILE%
%TIFFSETEXE% -s 282 96  %IMGDIR%\%INTERMEDIATEFILE%
%TIFFSETEXE% -s 283 96  %IMGDIR%\%INTERMEDIATEFILE% 
@echo off

Re: TIFF conversion RGB->CMYK 'the right way'

Posted: 2009-11-30T03:53:10-07:00
by rshea
Just realised that I should have included the output from 'identify' for these two files so here it is

First after the initial CMYK conversion :

Code: Select all

E:\bin\installed\ImageMagick-6.3.4-0-Q16>identify.exe -verbose H:\Shea\CMYKExperiment\ZENDGraphOutput-Step1.TIF
Image: H:\Shea\CMYKExperiment\ZENDGraphOutput-Step1.TIF
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 1600x981+0+0
  Type: ColorSeparationMatte
  Endianess: MSB
  Colorspace: CMYK
  Channel depth:
    Cyan: 8-bit
    Magenta: 8-bit
    Yellow: 8-bit
    Black: 8-bit
    Alpha: 1-bit
  Channel statistics:
    Cyan:
      Min: 0 (0)
      Max: 189 (0.741176)
      Mean: 6.89222 (0.0270283)
      Standard deviation: 32.7305 (0.128355)
    Magenta:
      Min: 0 (0)
      Max: 174 (0.682353)
      Mean: 4.21583 (0.0165326)
      Standard deviation: 24.2253 (0.0950013)
    Yellow:
      Min: 0 (0)
      Max: 170 (0.666667)
      Mean: 4.68948 (0.0183901)
      Standard deviation: 24.71 (0.0969021)
    Black:
      Min: 0 (0)
      Max: 229 (0.898039)
      Mean: 4.3009 (0.0168663)
      Standard deviation: 31.0871 (0.12191)
    Opacity:
      Min: 0 (0)
      Max: 0 (0)
      Mean: 0 (0)
      Standard deviation: 0 (0)
  Total ink density: 299%
  Colors: 3
  Histogram:
   1500968: #00000000 black
     39153: #86263C00 cmyk(134,38,60,0)
     29479: #BDAEAAE5 cmyk(189,174,170,229)
  Rendering intent: Undefined
  Resolution: 96x96
  Units: PixelsPerInch
  Filesize: 374.113kb
  Interlace: None
  Background color: white
  Border color: cmyk(223,223,223,0)
  Matte color: grey74
  Transparent color: none
  Page geometry: 1600x981+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: LZW
  Orientation: TopLeft
  Document: C:\20091130\OutputImages\ZENDGraphOutput-Step1.TIF
  Signature: 8d304c82822402c766c3560511e004f1e2abd60d8682464663048f248ce91ea9
  Software: ImageMagick 6.3.4 05/11/07 Q16 http://www.imagemagick.org
  Tainted: False
  User time: 0.063u
  Elapsed time: 0:01
  Pixels per second: 19.1906mb
  Version: ImageMagick 6.3.4 05/11/07 Q16 http://www.imagemagick.org
... and then after the attempts to make it more 'PIL' friendly ...

Code: Select all

E:\bin\installed\ImageMagick-6.3.4-0-Q16>identify.exe -verbose H:\Shea\CMYKExperiment\ZENDGraphOutput-Step2.TIF
Image: H:\Shea\CMYKExperiment\ZENDGraphOutput-Step2.TIF
  Format: TIFF (Tagged Image File Format)
  Class: DirectClass
  Geometry: 1600x981+0+0
  Type: ColorSeparation
  Endianess: MSB
  Colorspace: CMYK
  Channel depth:
    Cyan: 8-bit
    Magenta: 8-bit
    Yellow: 8-bit
    Black: 8-bit
  Channel statistics:
    Cyan:
      Min: 0 (0)
      Max: 189 (0.741176)
      Mean: 6.89222 (0.0270283)
      Standard deviation: 32.7305 (0.128355)
    Magenta:
      Min: 0 (0)
      Max: 174 (0.682353)
      Mean: 4.21583 (0.0165326)
      Standard deviation: 24.2253 (0.0950013)
    Yellow:
      Min: 0 (0)
      Max: 170 (0.666667)
      Mean: 4.68948 (0.0183901)
      Standard deviation: 24.71 (0.0969021)
    Black:
      Min: 0 (0)
      Max: 229 (0.898039)
      Mean: 4.3009 (0.0168663)
      Standard deviation: 31.0871 (0.12191)
  Total ink density: 299%
  Colors: 3
  Histogram:
   1500968: #0000000000000000 black
     39153: #868626263C3C0000 cmyk(134,38,60,0)
     29479: #BDBDAEAEAAAAE5E5 cmyk(189,174,170,229)
  Rendering intent: Undefined
  Resolution: 96x96
  Units: PixelsPerInch
  Filesize: 310.08kb
  Interlace: None
  Background color: white
  Border color: cmyk(223,223,223,0)
  Matte color: grey74
  Transparent color: black
  Page geometry: 1600x981+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: LZW
  Orientation: TopLeft
  Document: C:\20091130\OutputImages\ZENDGraphOutput-Step2.TIF
  Signature: 8f03458f3aeb074cb19124310c5d492693a5884d59e952d60ec334c772449e7e
  Software: Banana
  Tainted: False
  User time: 0.078u
  Elapsed time: 0:01
  Pixels per second: 15.9244mb
  Version: ImageMagick 6.3.4 05/11/07 Q16 http://www.imagemagick.org

E:\bin\installed\ImageMagick-6.3.4-0-Q16>




Re: TIFF conversion RGB->CMYK 'the right way'

Posted: 2009-12-01T02:33:14-07:00
by rshea
Just answering my own post here for the sake of future readers. It turns out that in using the 16 bit ImageMagick I was ending up with 16-bit/channel which the Python Image Library didn't like.

I was able to force the output to 8 bit using the

Code: Select all

-depth 8
argument. I didn't work this out myself it comes courtesy of Florian Hoch on the Python Image-SIG list http://mail.python.org/pipermail/image- ... 06013.html