Bug 692982 - Regression: input monochrome PostScript generates RGB PDF file
Summary: Regression: input monochrome PostScript generates RGB PDF file
Status: NOTIFIED INVALID
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: Color (show other bugs)
Version: master
Hardware: PC All
: P2 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-10 17:23 UTC by Marcos H. Woehrmann
Modified: 2014-02-17 04:43 UTC (History)
2 users (show)

See Also:
Customer: 32
Word Size: ---


Attachments
monochrome.ps (9.48 KB, application/postscript)
2012-04-10 17:23 UTC, Marcos H. Woehrmann
Details
monochrome.pdf (5.77 KB, application/pdf)
2012-04-13 18:23 UTC, Marcos H. Woehrmann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcos H. Woehrmann 2012-04-10 17:23:08 UTC
Starting with eac29c74c5e4ad815fe3ebc5607917ff278c7b2e the attached PostScript file generates an rgb PDF file instead of the monochrome PDF file generated by earlier versions.

The command line I'm using:

  bin/gs -sDEVICE=pdfwrite -o test.pdf ./monochrome.ps

commit eac29c74c5e4ad815fe3ebc5607917ff278c7b2e
Author: Michael Vrhel <michael.vrhel@artifex.com>
Date:   Tue Nov 16 14:48:31 2010 +0000

    Fix so that the initial gray color spaces in the graphic state are properly color managed. Previously, if we immediately started drawing in the document with a gray color space, the initial un-managed c
olor space in the graphic state was used and this was not associated with the specified gray source profile.  With this fix we initialize the stroking and filling color spaces to be ICC color spaces associated with the profile for default_gray in the icc manager.  Also a fix for an issue in littleCMS.  When merging profiles, littleCMS will often do an optimization where it approximates 1-D LUTs with an exponent operation for use during merging and interpolation of the profile structures.  If the curve is very steep, as in like a step function, it should not do this approximation.  This was an issue when we had profiles that provided thresholding operations with their 1-D LUTs.   I spoke with Marti about this issue a couple weeks ago.  This commit will create over 6000 differences in the regression test.   I reviewed many of these and they all are minor differences in gray colors as expected.  These are differences where we were drawing unmanaged colors.
    
    git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@11902 a1074d23-0009-0410-80fe-cf8c14f379e6
Comment 1 Marcos H. Woehrmann 2012-04-10 17:23:26 UTC
Created attachment 8522 [details]
monochrome.ps
Comment 2 Marcos H. Woehrmann 2012-04-13 18:21:43 UTC
Ken suggests that the input file is at fault:

From the setdistillerparams at the start of the file:

/ColorConversionStrategy /sRGB
Comment 3 Marcos H. Woehrmann 2012-04-13 18:23:25 UTC
Created attachment 8527 [details]
monochrome.pdf

If I run the monochrome.ps file through distiller the resultant pdf file (attached) is monochrome, as shown by gs with -dPDFDEBUG:

/BitsPerComponent 1 /ColorSpace /DeviceGray /DecodeParms
Comment 4 Marcos H. Woehrmann 2012-04-14 02:10:07 UTC
The customer reports:

I tried removing   /ColorConversionStrategy /sRGB and the file is still coming out in RGB.
Comment 5 Alex Cherepanov 2012-04-14 03:48:33 UTC
The file applies <</ColorConversionStrategy /sRGB>> twice.
Both instances should be removed to get DeviceGray color space.

Ghostscript handles ColorConversionStrategy differently than distiller.
See the Acrobat Distiller Parameters spec for details.
Comment 6 Ken Sharp 2012-04-14 15:02:38 UTC
(In reply to comment #5)
> The file applies <</ColorConversionStrategy /sRGB>> twice.
> Both instances should be removed to get DeviceGray color space.
> 
> Ghostscript handles ColorConversionStrategy differently than distiller.
> See the Acrobat Distiller Parameters spec for details.

As Alex correctly says the file sets ColorConversionStrategy (amongst other things) *twice*. You need to remove them both. If you do this then the default is used, which is /LeaveColorUnchanged.

As Alex also points out our implementation of this parameter differs from the Acrobat implementation. The Distiller implementation does not make sense to me, it leaves Gray objects in Gray space, despite the fact that the ColorConversionStrategy descibes the setting as 'Convert All Colors to sRGB'. Clearly this is not true, since it does not convert Gray. Our implementation does what it says, it converts all colours to the specified space. Note that our default value also differs from teh Distiller default of sRGB.

We don't support maintaining objects in DeviceGray while converting objects in other colour spaces.

If the customer wants to maintain Gray objects in DeviceGray space, they need to leave 'ColorConversionStrategy' set to /LeaveColorUnchanged.