Search code examples
pdfghostscriptcmyk

How to create CMYK color seperation combinations using GhostScript


I created color separations using

gs -sDEVICE=tiffsep -dNOPAUSE -dBATCH -dSAFER -r600x600 -sOutputFile=p%08d.tif input.pdf

The outputs are all greyscale separations as documented.

Questions 1. How do I combine just the CYAN and MAGENTA separations (or any combination of colors) to make a PDF file? 2. How do I make sure the output PDF from the combo is in color and not greyscale?

Thanks.


Solution

  • You should be able to use Imagemagick's convert to combine CMYK separations; references:

    Example: first, create RGB pdf with Latex (from https://softwarerecs.stackexchange.com/questions/19210/linux-gui-for-quick-browsing-of-cmyk-separations-of-multi-page-pdf); use this as test.tex:

    \documentclass{standalone}
    \usepackage{tikz}
    \begin{document}
    \begin{tikzpicture}
    \draw[fill=none,draw=black,line width=2pt] (0cm,0cm) rectangle (4cm,5cm);
    \draw[fill=red] (1cm,1cm) circle (1cm) ;
    \draw[fill=blue] (2cm,2.5cm) circle (1cm) ;
    \draw[fill=green] (3cm,4cm) circle (1cm) ;
    \end{tikzpicture}
    \end{document}
    

    ... then build the PDF with:

    pdflatex test.tex
    

    Split RGB pdf into CMYK separations as tiff images using Ghostscript (see original softwarerecs thread for images), which will be called:

    gs -sDEVICE=tiffsep -dNOPAUSE -dBATCH -dSAFER -r150x150 -sOutputFile=test%04d.tif test.pdf
    

    Merge/combine CMYK separations into a CMYK color tiff using Imagemagick:

    convert \
    test0001\(Cyan\).tif \
    test0001\(Magenta\).tif \
    test0001\(Yellow\).tif \
    test0001\(Black\).tif \
    -set colorspace CMYK -negate -combine combined.tif
    

    ... and here is how the final combined.tif looks like (I had to do convert combined.tif combined.png to upload it here, else .tif alone is not accepted):

    combined.png

    For comparison, here is a png derived from the original PDF (convert -density 150 -flatten test.pdf test.png):

    test.png

    Notice how the colors are slightly different, which is expected due to the colorspace roundtrip. Also, note that for more correct colors, you'll probably have to use ICC profiles during conversion...

    Finally, you should find a way to convert/import the final CMYK color TIFF into a PDF... (probably either ghostscript or imagemagick could do that, but I haven't tried it..)


    For just cyan and magenta - use a white image with the same size as the channel TIF separations, to insert it in place of the missing separations:

    convert -size 240x299 xc:white white.png
    

    ... and then do the merge again:

    convert \
    test0001\(Cyan\).tif \
    test0001\(Magenta\).tif \
    white.png \
    white.png \
    -set colorspace CMYK -negate -combine combinedCM.tif
    

    Here is the output (after convert combinedCM.tif combinedCM.png):

    combinedCM