Lasso Soft Inc. > Home

  • Articles

CMYK Colour Matching with ImageMagick

A recurring problem when converting EPS and PDF files with ImageMagick, is that the resulting RGB colours appear far too bright compared to the original. This may well be due to the fact that the original file is displaying colours that are meant for print, and therefore use the CMYK colour model.

You could of course this ImageMagick command line option:

convert -colorspace CMYK myfile.eps myfile.jpg


You now have a JPEG where the colours do indeed match those of the original, the only problem is... the JPEG is now in CMYK format, and not suitable for web use.

After extensive googling, I discovered that the only way to address this problem is to edit the ''delegates'' file.

ImageMagick uses ''GhostScript'' when converting PostScript files - so if you don't have GhostScript installed you're out of luck to begin with. The various commands passed to GhostScript by ImageMagick are defined in this ''delegates'' file.

If you're using an ImageMagick version older than 6.1, it will be called ''delegates.mgk'', otherwise it will be called ''delegates.xml''. In both cases you will be dealing with an xml file, which is usually located here:

/usr/local/lib/ImageMagick-6.x.x/config/delegates.xml
/usr/local/lib/ImageMagick-5.x.x/delegates.mgk


To edit this file, look for all occurrences of the GhostScript command, for example

<delegate decode="eps" encode="ps" mode="bi" command='"gs" -q -dBATCH 
      -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0
      -sDEVICE="pswrite" -sOutputFile="%o" -f"%i"' />


You need to add the command line option ''-dUseCIEColor'' to all of these GhostScript commands, so that they now look like this:

<delegate decode="eps" encode="ps" mode="bi" command='"gs" -q -dBATCH 
      -dSAFER -dUseCIEColor -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0
      -sDEVICE="pswrite" -sOutputFile="%o" -f"%i"' />


Now that you have edited the ''delegates'' file, JPEGs created from PostScript-based files should display with far more accurate colours. You can add the command line option ''-colorspace RGB'' (When calling ImageMagick - ''not'' in the delegates file), which appear to give slightly different results.

convert -colorspace RGB myfile.eps myfile.jpg


...and that's all there is to it  :-)

Author: Pier Kuipers
Created: 11 Sep 2008
Last Modified: 1 Mar 2011

Comments

No comments found
You must be logged in to comment.

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft