[gs-devel] PDF rasterization for driverless printing: Color Management
till.kamppeter at gmail.com
Tue May 25 17:47:24 UTC 2021
I have now committed my first approach of auto-selection of the color
space and depth in cups-filters:
Here is the commit:
The basic principles are:
- Depending on the output format (PWG or Apple Raster) the printer IPP
attribute pwg-raster-document-type-supported or urf-supported is used
to determine which color space/color depth combos are available.
- A color space of sGray, sRGB, AdobeRGB, Device... is selected
depending on input data, presence of a custom ICC profile, desire to
print in color, gray, or bi-level (print-color-mode job attribute).
- If the requested color space is available it gets selected, otherwise
the default color space is chosen: For color printing (or if no mono
color space is available) AdobeRGB if available otherwise sRGB, for
mono printing sGray.
- Within the selected color space the lowest color depth (usually 8 bit
per color) is chosen, if print-quality is set to "high" the highest
color depth (16-bit if available).
My commit implements this only for the ghostscript() filter function
(gstoraster CUPS filter) for now, but commonly used code is in separater
library function so other filter functions are easy to update, too.
This is implemented for both using the filter function PPD-less, based
on printer and job IPP attributes and as CUPS filter with a PPD file
generated by the PPD generator of libcupsfilters (for example via the
"driverless" utility) for a driverless IPP printer.
The generated PPD files are appropriately changed, by including both
pwg-raster-document-type-supported and urf-supported IPP attributes of
the printer as PPD attributes ("*cupsPwgRasterDocumentTypeSupported" and
"*cupsUrfSupported") and by the "ColorModel" option now mirroring the
print-color-mode IPP attribute, listing the choices from
print-color-mode-supported, and not including pseudo-PostScript code any
more as these parameters now get auto-selected by the filter. Formerly,
the PPD generator created one "ColorModel" choice for each color
space/depth combo for manual selection.
The ghostscript() filter function currently does not pre-check the
content of incoming PDF files for best choice of color space, the color
space requested from the color space selector function
(cupsRasterSetColorSpace() in cupsfilters/raster.c) is always the
default color space. Only if there is a custom color profilea Device...
color space is requested.
Ghostscript is called with both "-dUsePDFX3Profile" and
"-sOutputICCProfile=..." where Ghostscript's standard ICC profiles for
sGray, sRGB, and AdobeRGB are used if no custom profile is specified.
There is most probably room for improvement, any hints are welcome.
Also more filter functions (...toraster) will be moved over.
On 10/05/2021 19:03, Till Kamppeter wrote:
> I am currently working on how to cope with extended color options for
> higher print quality on driverless IPP printers.
> The discussion so far is here (Thread: Make use of extended color spaces
> on IPP printers):
> I have found a solution to make use of optional 16 bit per color
> (instead of 8 bit per color) on some printers.
> My problem is that there are printers which not only offer the standard
> sRGB but also offer AdobeRGB and DeviceRGB. At least with AdobeRGB one
> can get a higher color gammut, Device RGB allows to use a
> printer-specific ICC profile (loaded from printer following URI in
> "printer-icc-profiles" printer IPP attribute or obtained by
> What should happen here to have the best driverless printing experience
> for uses is the following:
> - The user should only choose between auto, grayscale, and color for
> color mode, he should not manually choose sRGB, AdobeRGB, DeviceRGB,
> ... This should be selected automatically.
> - 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
> - If the printer supports DeviceRGB and the printer's ICC profile is
> available, output (at least if the original was sRGB) should be
> converted to DeviceRGB with the printer's IPP profile.
> - The client has access to the CUPS queue's printer IPP attributes and
> so also to the printer's color space support info, so a client
> application could already send the data in the desired color space but
> does not necessarily do it.
> If the incoming print job is PDF, the rasterization is done by
> Ghostscript, called via the gstoraster CUPS filter (or the ghostscript()
> filter function of cups-filters 2.x) with a command line like (producing
> PWG Raster):
> gs -dQUIET -dSAFER -dNOPAUSE -dBATCH -dNOINTERPOLATE -dNOMEDIAATTRS
> -dShowAcroForm -sstdout=%stderr -sOutputFile=%stdout -sDEVICE=cups
> -sMediaClass=PwgRaster -sOutputType=Automatic -r600x600
> -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=792 -dcupsBitsPerColor=8
> -dcupsColorOrder=0 -dcupsColorSpace=19
> -dcupsBorderlessScalingFactor=0.0000 -dcupsInteger1=1 -dcupsInteger2=1
> -scupsPageSizeName=na_letter_8.5x11in -I/usr/share/cups/fonts -c -f -_
> The cupsColorSpace is
> 18: sGray
> 19: sRGB
> 20: AdobeRGB
> 1: DeviceRGB
> 3: DeviceGray
> 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?
> - 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?
> - 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?
> Any help is appreciated
More information about the gs-devel