[gs-devel] PDF rasterization for driverless printing: Color Management

Till Kamppeter till.kamppeter at gmail.com
Wed May 19 07:35:06 UTC 2021

[ Michael Vrhel, please "Reply to All", so that the answer also goes
   onto the list, thanks ]

Michael, thank you very much.

Now I have the following question:

Generally, I have these possibilities to send output to the printer 
(printer is driverless IPP):

1. SGRay:      -sOutputICCProfile="sgray.icm"  (is this name correct?)
2. SRGB:       -sOutputICCProfile="srgb.icm"
3. AdobeRGB:   -sOutputICCProfile="a98.icm"
4. DeviceGray: -sOutputICCProfile="my_gray_profile.icm"
5. DeviceRGB:  -sOutputICCProfile="my_rgb_profile.icm"
6. DeviceCMYK: -sOutputICCProfile="my_cmyk_profile.icm"

The printer usually does not support all profiles (mono printers 
generally only 1 and 4, some color printers support AdobeRGB others not, 
some printers support your own profile, some not, ...), therefore I 
cannot simply, blindly apply the input file's output intent 
(-dUsePDFX3Profile) as the printer will perhaps not support it, am I right?

What I want to do is to use the PDF files output intent if the printer 
supports it (the response to a get-printer-attributes IPP request to the 
printer tells which color spaces are supported), meaning if it is 
AdobeRGB only print in AdobeRGB if the printer supports it, otherwise 
fall back to sRGB.

Something like

if (output_intent = AdobeRGB)
   if (printer supports AdobeRGB)
     gs ... -dUsePDFX3Profile ...
     gs ... -sOutputICCProfile="srgb.icm"

So what I need for that is, before rendering, querying the output intent 
from the PDF input file. How do I do that? Is there a Ghostscript 
command line doing that query?

The same would apply to DeviceRGB but DeviceRGB only being accepted if, 
in addition to the printer supporting it, the color profile being 
present. Here I would also need a way to check whether the input PDF 
file has an embedded output color profile (does such a thing exist?) 
before rendering it.

This should work automatically and transparent to the user, as most 
users do not know anything about color management, and especially users 
of a driverless IPP printer want it to "just work".


On 19/05/2021 08:54, Ken Sharp wrote:
> Hi Till,
> Sorry this has taken so long to get replied to, our colour expert 
> (Michael Vrhel) isn't on gs-devel and didn't realise there was a 
> question requiring his input.
> Because he isn't subscribed to gs-devel he can't answer directly, so I'm 
> posting this to the list on his behalf.
> 8<-----------------------------------8<--------------------------------8<
> Hi Till,
> See my answers below:
>  >- If an incoming PDF file is sRGB, it should be rasterized to an sRGB
>  >   Raster file and sent to the printer
>  >
>  >- If an incoming PDF is AdobeRGB and the printer supports AdobeRGB, it
>  >   should be rasterized in AdobeRGB
> The idea that the incoming PDF file is sRGB or is AdobeRGB makes no sense.
> A PDF page can define many objects each in different color spaces.  Some
> objects could be in sRGB some could be in AdobeRGB.  There is the 
> concept of
> a PDF file having an output intent.  In this case, that is the color space
> to which the rendering should be targeted.  If the input file has an
> OutputIntent and you wish to render to that target, then you would add in
> the following command line option:
> -dUsePDFX3Profile
> If you wish to render to a particular output color space (e.g. sRGB or
> AdobeRGB or some target ICC profile for the device) then you will want to
> specify the following:
> -sOutputICCProfile="ICC_profile.icm"
> Where you can specify for example
> "srgb.icc"  for sRGB
> "a98.icc"   for AdobeRGB (1998)
> as these ship with with Ghostscript, or you can specify the profile file
> name that want to use.
> If you use both -sOutputICCProfile="ICC_profile.icm" and -dUsePDFX3Profile
> and there is an output intent included in the PDF file, the output 
> intent is
> an intermediate mapping (i.e. proofing profile) that will be used.
> Unless you really want that, it would be my recommendation that you just 
> use
> -sOutputICCProfile="ICC_profile.icm" and not -dUsePDFX3Profile
>  >
>  >Now my questions are
>  >
>  >- Does this command line convert the input to the destination color
>  >   space (the cupsColorSpace value)? So that if I set cupsColorSpace=20
>  >   that I always get AdobeRGB output? Or do I need any additional command
>  >   line arguments?
> You have to specify what I said above to map to the different color spaces.
>  >- If I opt for DeviceRGB (cupsColorSpace=1) or DeviceGray
>  >   (cupsColorSpace=3) how do I supply the ICC profile (which I have in a
>  >   file) to the Ghostscript call so that the output is in this color
>  >   space? Which command line options do I need to add?
> -sOutputICCProfile="ICC_profile.icm"  where ICC_profile.icm is the file you
> said you have.
>  >- If I print a photo from a user application and the application sends
>  >   it as PDF but in AdobeRGB would the above command line (with
>  >   cupsColorSpace=20) conserve the AdobeRGB and not do any inbetween
>  >   conversion to sRGB or anything else?
> Again, this idea of a PDF being in AdobeRGB makes no sense to me.  But if
> there is content in the PDF that is defined in that color space and you
> specified
> -sOutputICCProfile=" a98.icc "
> There should not be any loss in color fidelity in this case.
> Regards,
> Michael
> 8<-----------------------------------8<--------------------------------8<
>                      Ken

More information about the gs-devel mailing list