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

Till Kamppeter till.kamppeter at gmail.com
Wed May 19 10:53:22 UTC 2021

On 19/05/2021 10:02, Jonas Smedegaard wrote:
>> 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?
> Sounds wrong: color intent is about user intent, not device support.
> (this is a color management principle, not specific to Ghostscript)
>> 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.
> It sounds wrong to set an output intent simply based on support by the
> targeted printer.
> As I understand it, output intent means "whatever the currently targeted
> device is capable of, this (potentially different) color space is the
> truly intended one".  I.e. setting output intent is not normally wanted
> at all.
> With the above in mind, try read this again:
>>> 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
> ...and notice the "you really want that" part.  You _really_ want CUPS
> to do proofing by default for devices that supports it?

Thanks, Jonas.

What I want to have is the following:

I want that if a user prints an arbitrary (PDF) file that he gets the 
best color gammut which the printer supports. This should work fully 
automatically, as most users do not know about color management.

In my case the printer is a driverless IPP printer which accepts print 
jobs as Raster (Apple or PWG Raster). The printer can be queried to know 
which color spaces it supports. In case of color output it is sRGB, 
AdobeRGB, DeviceRGB, and DeviceCMYK, in case of monochrome output it is 
sGray and DeviceGray.

Any of the Device... color spaces need a color profile be supplied to 
the print job, Sgray, sRGB, and AdobeRGB are standard color spaces for 
which Ghostscript includes the profiles.

Here I am especially thinking about the gstoraster CUPS filter 
(ghostscript() filter function in cups-filters 2.x) which takes a PDF 
file (usually coming from a user application when the print function is 
used) and turns it into CUPS Raster (CUPS' rastertopwg turns this into 
Apple Raster then) or PWG Raster. For both Apple Raster and PWG Raster 
the printer tells which color spaces it supports.

So when this filter gets used by a CUPS print job it gets information 
about the supported color spaces (via the PPD file, for both Apple and 
PWG Raster) and the final data format (Apple or PWG Raster, via 
FINAL_CONTENT_TYPE environment variable). With this information and the 
possibility to perhaps pre-examine the input file before rendering it, 
the filter has to select the best color space for this job.

One can assume that all printers support sGray and sRGB, several also 
support AdobeRGB and a few also Device...

Now what is the best strategy now to make best use of the color spaces 
the printer support, to once not cut down the color gammut of the input 
file when sRGB gets used on a printer which could do AdobeRGB and also 
not loose color depth if a n input file with a color gammut fitting into 
sRGB is printed in AdobeRGB.

The process should be fully automatic: If needed, first read the input 
file and pre-examine it whether it needs AdobeRGB or not, the decide on 
whether to render the data in sRGB or AdobeRGB, then render with correct 
Ghostscript command line.

Is this the correct approach? And if yes, how do I pre-examine the input 
PDF file? Or should I simply render everything in AdobeRGB if the 
printer supports AdobeRGB?


More information about the gs-devel mailing list