0

I'm planning to use colorprofiles while converting pdf's to jpg/png/pdf(low res/high res/rgb/cmyk) but (Question 1)I could not find how could I determine if a input document has an icc profile and if it has do i use it to help my conversion. Is there a ghostscript command to determine icc profiles

I found a gs command to convert to pdf as below from link:

gs -o cmyk-doc.pdf      \
   -sDEVICE=pdfwrite    \
   -dOverrideICC=true   \
   -sDefaultCMYKProfile=/path/to/mycmykprofile.icc \
   -sOutputICCProfile=/path/to/mydeviceprofile.icc \
   -dRenderIntent=3     \
   -dDeviceGrayToK=true \
    input-doc.pdf

(Question 2)If my input document has a profile, can I skip the option -sDefaultCMYKProfile and only pass the required -sOutputICCProfile.

Binoy Cherian
  • 364
  • 1
  • 6
  • 23

1 Answers1

0

You can't use Ghostscript to determine if a PDF file has ICC colour profiles. Note there can be numerous colour profiles in a PDF file. Each colour can be in its own space, and each space can use a different ICC colour profile. That's in addition to the OutputIntent profile. On the other hand, you don't need to care.

For rendering you are basically looking at a conversion like this:

input colour -> CIE representation -> output colour

The input colour (in PDF) can be Gray, RGB, CMYK, Separation, DeviceN or one of the CIE spaces; Lab, ICC.

The output colour, for rendering will need to be one of Gray, RGB, CMYK or 'separated' (where each component rendered to a separate gray image).

The OutputICCProfile controls the second half of that conversion, the Default* profiles control the first half of that conversion, when the colour space isn't already one of the CIE spaces.

Taking question 2 first....

You never need to supply the DefaultCMYKProfile. That is used to override the Ghostscript default CMYK->CIE profile. You can use this if you happen to know that the input file is in CMYK space, and that it was a characterised CMYK space. In which case supplying the profile for that space would do a better job of converting from CMYK to CIE than the Ghostscript default one. However this is rare and generally only true in controlled workflows.

For question 1:

You only really care if the PDF file does not contain ICC profiles but instead defines colours in a device space such as RGB or CMYK. In that case, and assuming the PDF file has been created for a colour controlled workflow, you might assume that all the colours are in the same space, in which case I believe you would want to use the OutputIntent profile from the PDF file, or override the Ghostscript default (see below). There is extensive documentation on the use of ICC profiles here.

The OutputICCProfile is used with rendering devices in order to characterise the output space. So if you are rendering to RGB output you might use a specific RGB ICC profile to convert from CIE space to RGB space. That profile might additionally then be attached to the output file (eg JPEG) and a conforming reader would be able to use that profile to convert the RGB samples back into CIE space in order to use yet another profile to convert to a different characterised space (eg the profile for your display).

Now that's for rendering, ie creating a bitmap image. The pdfwrite device, on the other hand, goes to considerable lengths to maintain input colours in their original colour space. If you want to convert them into a different space then you need to set -sColorConversionStrtaegy. The command line you've quoted won't do that. If you want it converted to a characterised CMYK space then you would indeed supply the OutputICCProfile, but you do need to specify -sColorConversionStrategy=DeviceCMYK.

KenS
  • 30,202
  • 3
  • 34
  • 51