34

I am submitting a paper to a conference in a few days and just noticed they require all images to be in CMYK color space. Is there a quick easy way to check if they are?

And if they are not, is there a quick easy way to convert them to CMYK, preferably via PDFlatex or another Latex component (best) or via a batch utility (good) or something so I don't have to do it manually (bad). If a batch is the solution, I'd like to be able to take a copy of my working folder tree, point a batch utility at it, and have it convert everything therein to CMYK if it's not already.

My images are mostly jpeg, but I think I might have some PNGs as well.

2 Answers 2

31

PNG's cannot be in the CMYK colorspace, so if you have some you will need to convert them to JPGs.

I only use linux so my solution may not be relevant but imagemagick is a good commandline tool to batch convert images.

if you use colour within your document you will need to load the xcolor package with the cmyk option to make sure that all colour definitions are translated to the CMYK colorspace (although it will not convert included images, only colours of used directly in the latex document.

One other note if you use fontspec, for font definitions, using the [Color=...] options as fontspec doesn't support CMYK colours. instead you will need to use the \color{} command from xcolor instead.

An example of imagemagick commandline conversion would be:

convert image-rgb.jpg -colorspace CMYK image-cmyk.jpg

You have to be aware that that the converted image will look different to the original one.

You can check what colorspace the image is encoded in by using the identify command:

identify -verbose image.jpg

and look for the Colorspace: field. In a POSIX environment with grep available simply doing

identify -verbose image.jpg | grep "Colorspace:"

should give you the answer.

Edit: As noticed, the default conversion done by IM via the -colorspace option is not very good. The IM manual advise to use the -profile <filename>.icc option instead to get better results. This requires having the appropriate icc profile file available.

On a linux distribution with ghostscript installed, there is a default_cmyk.icc file which gives already a much better result than the one obtained using the -colorspace CMYK option. However, Adobe make their ICC profiles availble for free, and these can be used by IM to produce even better results. The Adobe ICC profiles are available from the Adobe website. The package comes with 8 RGB profiles and 14 CMYK ones so plenty to choose from. I am tried both the WebCoatedSWOP2006Grade5.icc and the USWebCoatedSWOP.icc, and both give very good results with slight difference between them. However, if the conference insist on CMYK colorspace, it might be worth asking them if they can provide you with their ICC profile, you will therefore make sure that all the colours in your images will print properly.

Once you have the ICC file available, you can then use them with imagemagick like this:

convert image-rgb.jpg -profile "\path\to\cmyk_profile.icc" image-cmyk.jpg 
11
  • ImageMagick is probably a good strategy, however, it's like a swiss army knife: One is easily overwhelmed by the options and possibilities. So could you give some concrete examples how to invoke convert from ImageMagick to do the requested conversions? That could improve the usability of your answer quite a bit.
    – Daniel
    Mar 15, 2012 at 8:10
  • ImageMagick is as easy on the command line in Windows as in *nix. Bat-scripts are the way to go.
    – nickpapior
    Mar 15, 2012 at 9:49
  • @Daniel The reason I hadn't included the imagemagick sample command line was that I felt it was beyond the scope of this forum. But I have now included it.
    – ArTourter
    Mar 15, 2012 at 13:01
  • 1
    To keep the quality of png images you can always convert them to pdf. (this would just be a format change, not a vectorisation of the image) with convert image-rgb.png -colorspace CMYK image-cmyk.pdf. I do not know what compression algorithm the resulting image has but it does not have the usual JPG compression artefacts and the file size is fairly similar to the original, and it is definitely in the CMYK colorspace.
    – ArTourter
    Mar 16, 2012 at 14:03
  • 1
    Is it possible to convert only the final pdf with ImageMagick? This would have the advantage of leaving the original files untouched and is possibly easier when dealing with a file with lots of images. Are there any downsides to this approach?
    – Jonathan
    Sep 18, 2013 at 19:04
12

I would suggest to use JPEG-in-bilevel-PDFs created by imagemagick. So far it is the only reliable solution I found that can handle CMYK as well as keep transparancy of source-PNGs, while making them easy to handle within pdflatex or xelatex.

I usually do the following:

convert rgb.jpg +profile "*" -profile "path/to/rgb.icc" -profile "path/to/cmyk.icc" -strip -sampling-factor 1x1 -quality 95 -compress JPEG cmyk.pdf

or

convert rgb.png +profile "*" -profile "path/to/rgb.icc" -profile "path/to/cmyk.icc" -strip -sampling-factor 1x1 -quality 100 -compress JPEG cmyk.pdf

Note:

  • convert behaves different if the source image has an embedded profile or not. That is very annoying. If it does not have one, you need to provide TWO -profile parameters (a source and a target profile), or no conversion will happen, and usually the source file will not have a profile if it is a self-made image. I therefore recommend to remove an maybe existing profiles in the image using +profile "*" when you are sure it is a RGB file, so that all files are handled uniformly, and then 2 profiles should be specidifed using "-profile"
  • Specifying the -compress JPEG is necessary so that the final pdf will contain a jpg (plus transparency mask). Otherwise if the input file is e.g. rgb.png, it will not become a JPEG in the pdf, thus the CMYK conversion in in vain due lack of CMKY-Support in the png.
  • If the source file is a PNG, a final quality of 100 is a good choice for the jpg-in-pdf. Otherwise, take any other compression level you'd like. Usually 95 is still good enough.
  • If you do identify -verbose on the resulting cmyk.pdf, it will tell you the "K" channel is empty. I think this is a bug of identify, as the K channel is fine if you binary extract the jpeg from the PDF.
  • The resulting pdf will have 2 "layers": the image data as JPG, plus a 8-bit transparency layer that will be populated if the source file had transparency (e.g. was a png).
  • The -strip will remove the embedded color profile from the final file. Otherwise imagemagick wiill copy the cmyk.icc file into the final pdf, increasing it by usually around 600k.
  • Resetting the sampling-factor to 1x1 is necessary or the color conversion library of imagemagick will blur the image.
  • imagemagick has a builtin "-colorspace CMYK" function, but that will only do a simple conversion and probably result in wrong final CMYK tones. Therefore, use the a profile of the target printer/company/etc.

Converting always to jpg-in-pdfs (even if the source was a PNG) makes it easier in LaTeX, as now you have uniform pdfs to use independent of their source.

I can't stress the fact enough that you need two profile for convert to do it's job. I fallen into this pit a lot.

To obtain suitable color profiles, I recommend the sRGB v4 Preference from http://www.color.org/srgbprofiles.xalter, for the CMYK color profile pick one from Adobes package (in Europe for example it will often be ISO Coated FOGRA39): http://www.adobe.com/support/downloads/product.jsp?product=62&platform=Windows

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .