我正在寻找一种将RGB颜色的PDF转换为CMYK颜色的方法。我已经尝试过不同的程序,比如Ghostscript和PStill,但都没有得到满意的结果。是否有人知道一种可以100%正常运行并能通过命令行运行的方法?
可以使用Ghostscript实现,但需要使用来自argyll的collink工具帮助准备转换(DeviceLink) ICC配置文件,以定义如何正确地将特定RGB转换为特定CMYK配置文件。
Get the RGB input ICC profile your documents have, such as some basic sRGB icc file, if the original is supposed to be in sRGB. (If it's AdobeRGB use AdobeRGB input ICC etc.)
Get the CMYK output ICC profile you would like documents convert to, for modern European offset printers nowadays a reasonable choice would be eciCMYK v2 which is a "CMYK exchange color space profile". (Also called FOGRA 59).
Install collink tool from argyll package.
Let collink create DeviceLink profile to calculate how to properly convert RGB to the particular CMYK. If you use "-f" parameter it will do an exception for neutral, grey and black color so they are not as rich CMYK black but a plain K black. It is expected to have both icc profiles in the working folder). Details in documentation at https://www.argyllcms.com/doc/collink.html saying for the -f parameter "Force neutral colors to be K only output."
collink -v -f sRGB.icm eciCMYK_v2.icc sRGB_to_eciCMYK_v2.icc
The result is a DeviceLink icc file sRGB_to_eciCMYK_v2.icc.
Then create a control-sRGB.txt file to tell ghostscript parameters which devicelink profile to use for which and with which type of intent. You can do collink twice, make two profiles one for images to not put blacks to plain black but keep the blacks rich, and then another for text and graphics to force black content be purely from the black (K) ink plate. Note the separator between parameters in control file must be tabs, not spaces. Example:
Image_RGB sRGB_to_eciCMYK_v2.icc 0 1 0
Graphic_RGB sRGB_to_eciCMYK_v2.icc 0 1 0
Text_RGB sRGB_to_eciCMYK_v2.icc 0 1 0
Finally run Ghostscript this way, where 1-input-rgb.pdf is the input PDF in RGB, and 2-output-cmyk-from-sRGB.pdf is the output CMYK PDF:
gs -o 2-output-cmyk-from-sRGB.pdf \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=CMYK \
-sSourceObjectICC=control-sRGB.txt \
1-input-rgb.pdf
注意: 不要依赖于Imagemagick识别命令等,它不能可靠地告诉您所得到的PDF中的所有对象是否为CMYK,它实际上仍然会写入RGB,这实际上并不正确。
图片: