How to Convert Image Color Space to CMYK in ImageMagick?

This article provides a quick overview and step-by-step guide on how to change an image’s color space to CMYK using the ImageMagick command-line tool. You will learn the basic conversion commands, how to handle color profiles for professional printing, and how to verify that your output image is correctly set to the CMYK color space.

Basic CMYK Conversion

To convert an image from its current color space (usually RGB) to CMYK, you use the magick command (or convert in older versions of ImageMagick) along with the -colorspace operator.

magick input.jpg -colorspace CMYK output.jpg

This command performs a direct mathematical translation of the channels. While this works perfectly for general use cases, it may not perfectly match the exact ink profiles required by commercial printers.

Professional Printing with Color Profiles

For high-quality printing, it is highly recommended to use ICC color profiles instead of a generic colorspace conversion. This ensures the colors look exactly as intended when printed on paper. To do this, you use the -profile option.

When using profiles, you must first define the input profile (usually sRGB) and then define the output CMYK profile (such as U.S. Web Coated SWOP v2 or Coated FOGRA39).

magick input.jpg -profile sRGB_Profile.icc -profile USWebCoatedSWOP.icc output.jpg

Note: If your input image already contains an embedded color profile, you only need to specify the target CMYK profile in the command. ImageMagick will automatically handle the translation from the embedded profile to the new one.

Verifying the Color Space

After running your command, you can verify that the conversion was successful by inspecting the image metadata using the identify command.

magick identify -format "%[colorspace]" output.jpg

If the conversion was successful, the terminal will output CMYK.