Varun Joshi
Varun Joshi

Reputation: 689

Black color showing on CMY channels when converted to CMYK using GhostScript

I am trying to generate a PDF using a library called wkhtmltopdf to create an RGB pdf. I am then using ghostscript to convert it to a CMYK format, however, the black text that is in the pdf is not pure black [cmyk(0,0,0,1)].

The black color is visible in other channels.

The command for ghostscript is:

gs -dBATCH -dNoOutputFonts -dNOPAUSE -dTextBlackPt=1 -dBlackPtComp=1 -sTextICCProfile -dNOCACHE -sDEVICE=pdfwrite -sProcessColorModel=DeviceCMYK -sColorConversionStrategy=CMYK -sOutputICCProfile=ps_cmyk.icc -sDefaultRGBProfile=srgb.icc -dOverrideICC=true -dRenderIntent=1 -sOutputFile=cmyk11.pdf test-rgb-cmyk.pdf

Any help would be massively appreciated! Been at this for a few days now. Thanks!

Ghostscript version: 9.26 Example pdf: https://drive.google.com/file/d/1nSM05b0O6fEb_0Z1rr2REbOPQAdwolTA/view?usp=drivesdk

Upvotes: 0

Views: 547

Answers (2)

KenS
KenS

Reputation: 31199

Almost all the switches you are using will have no effect with the pdfwrite device, they are specific to rendering devices (bitmap output). In particular the -dTextBlackPt, -dBlackPtComp and TextICCProfile will do nothing.

In order to properly colour manage the conversion you need to specify input and output ICC profiles. If memory serves, you need to alter the default Gray, RGB and CMYK profiles that Ghostscript uses.

Really I'd need to see an example file (as simple as possible) and it would obviously be useful to know which version of Ghostscript you are using. If it's not the current version then I'd suggest you upgrade anyway.

Upvotes: 1

Martin Malec
Martin Malec

Reputation: 11

Examples of Ghostscript commands to convert PDF from sRGB or eciRGB_v2 to eciCMYK_v2 (FOGRA 59) while keeping black plain (K only), not rich (CMYK)

I managed to convert PDF file in RGB to CMYK while keeping RGB black #000000 plain K black, not rich CMYK black.

DeviceLink ICC had to be created from e.g. eciRGB_v2 (or sRGB, if your source is sRGB) profile to the appropriate CMYK profile using collink tool (from argyll package) with the "-f" attribute to hack the black colors.

Ghostscript is then called with a control file declaring use of the profile and its parameters.

Example of making the DeviceLink RGB to CMYK profile

collink -v -f eciRGB_v2.icc eciCMYK_v2.icc eciRGB_v2_to_eciCMYK_v2.icc

Example of a control file to map eciRGB_v2 to eciCMYK_v2 (control-eciRGB_v2.txt)

Image_RGB   eciRGB_v2_to_eciCMYK_v2.icc 0   1   0
Graphic_RGB eciRGB_v2_to_eciCMYK_v2.icc 0   1   0
Text_RGB    eciRGB_v2_to_eciCMYK_v2.icc 0   1   0

(note must be separated by tabs, not spaces)

Sample ghostscript command to do the actual conversion

gs -o 2-output-cmyk-from-eciRGB.pdf \
       -sDEVICE=pdfwrite \
       -sColorConversionStrategy=CMYK \
       -sSourceObjectICC=control-eciRGB_v2.txt \
       1-input-rgb.pdf

Upvotes: 0

Related Questions