Bug 691109 - -sDEVICE=pdfwrite -dConvertCMYKImagesToRGB=true
Summary: -sDEVICE=pdfwrite -dConvertCMYKImagesToRGB=true
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 8.71
Hardware: PC Windows XP
: P4 normal
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-12 08:06 UTC by Thierry MARX
Modified: 2010-09-27 09:38 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
cmyk pdf (3.61 MB, application/pdf)
2010-02-15 01:21 UTC, Thierry MARX
Details
Additional (simple) test case (7.40 MB, application/postscript)
2010-06-06 10:59 UTC, mw
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry MARX 2010-02-12 08:06:15 UTC
this command line crash: 
gswin32c -sDEVICE=pdfwrite -dConvertCMYKImagesToRGB=true -sOutputFile=test.pdf 
input.pdf

If I Use the duseicecolor=true it does not crash but the output file is not 
readeable...

Is there any way to convert my cmyk pdf to rgb one?
Comment 1 Ken Sharp 2010-02-12 08:19:51 UTC
First I would suggest trying a more recent version of Ghostscript, the current
release is 8.71.

If that continues not to work, please attach a sample file here.
Comment 2 Thierry MARX 2010-02-15 01:21:17 UTC
Created attachment 5954 [details]
cmyk pdf
Comment 3 Thierry MARX 2010-02-15 01:24:07 UTC
I try it with gs 8.70 win32, still the same. There is no 8.71 binaries for 
windows. Here is a cmyk PDF that produce the problem.
Comment 4 Hin-Tak Leung 2010-02-16 19:32:59 UTC
segfault with svn trunk r10710 (that's a few commits before the 8.71 freeze);
with ghostpdl language switch build against icc_branch r10720, it generates a
370k pdf which is incomplete but no error message. Adding Michael for the latter
problem.
Comment 5 Thierry MARX 2010-03-15 09:36:23 UTC
any news about a solution?
Comment 6 Ken Sharp 2010-03-19 14:41:05 UTC
The seg fault is also caused by a colour space. During a grestore the colour space (pgs->color_space) is pointing at what appears to be uninitialised memory.

Since it processes correctly when we don't convert the images I guess this is the source of the problem, though I can't see why.

The exhibit file is large and complex, this will take some considerable time to work through.
Comment 7 mw 2010-06-06 10:59:57 UTC
Created attachment 6354 [details]
Additional (simple) test case

Attached you will find a new test case for this bug.
It contains a single page with a CMYK image.
Comment 8 mw 2010-06-06 11:14:50 UTC
Hi Ken,

I also stumbled about this.
Would be nice if this could be fixed.

Looks like pdfwrite crashes as soon as ConvertCMYKImagesToRGB=true is defined and a CMYK image is present. 

Strange enough, if ColorConversionStrategy=/sRGB is defined (and ConvertCMYKImagesToRGB=false), the file is created with no obvious errors (and as far as I understand it, the image will be converted to RGB in that case also).

To help you I added an additional test case.

The bug is existing in the following GS versions:

8.56, 8.60, 8.62, 8.63, 8.70, 8.71
8.54 works properly

Kind regards,
Markus
Comment 9 Ken Sharp 2010-06-07 13:50:55 UTC
(In reply to comment #8)

> Strange enough, if ColorConversionStrategy=/sRGB is defined (and
> ConvertCMYKImagesToRGB=false), the file is created with no obvious errors (and
> as far as I understand it, the image will be converted to RGB in that case
> also).

Its a 'calibrated RGB' space. In PostScript terms this is a CIE colour space. It is only properly represented in a PDF file by using an ICCBased colour space, though the CalRGB space is a reasonable approximation. 

Although these are both 3 component spaces, the ICCBased space will result in an image which is not exactly RGB.
Comment 10 mw 2010-06-07 20:13:14 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > Strange enough, if ColorConversionStrategy=/sRGB is defined (and
> > ConvertCMYKImagesToRGB=false), the file is created with no obvious errors (and
> > as far as I understand it, the image will be converted to RGB in that case
> > also).
> Its a 'calibrated RGB' space. In PostScript terms this is a CIE colour space.
> It is only properly represented in a PDF file by using an ICCBased colour
> space, though the CalRGB space is a reasonable approximation. 
> Although these are both 3 component spaces, the ICCBased space will result in
> an image which is not exactly RGB.

Thank you for this information.

What is the status of this bug?
It looks like ConvertCMYKImagesToRGB does not work at all currently.
Comment 11 Ken Sharp 2010-06-08 07:15:22 UTC
(In reply to comment #10)
 
> What is the status of this bug?
> It looks like ConvertCMYKImagesToRGB does not work at all currently.

It appears to be a bug, it has not been reported by a commercial customer and so does not get a high priority. It will be dealt with when developer time is available.
Comment 12 mw 2010-06-08 12:54:22 UTC
(In reply to comment #11)
> It appears to be a bug, it has not been reported by a commercial customer and
> so does not get a high priority. It will be dealt with when developer time is
> available.

OK. Please tell me if I can help in any way.
Comment 13 Ken Sharp 2010-09-27 09:38:06 UTC
In fact it is not the presence of a CMYK image which causes the problem. The 
issue arises because both example files contain an imagemask.

Imagemasks do not have a colour space of their own, they are drawn using the 
current colour and space. The code for converting CMYK images to RGB was 
checking the image colour space to see if it was CMYK before converting, but
the masks have a NULL colour space, dereferencing this causes a crash.

Revision 11744:
http://ghostscript.com/pipermail/gs-cvs/2010-September/011766.html

resolves this by checking for a NULL colour space, if it is NULL we know this
is a mask, and masks never need to be converted, so we can simply return,
setting the conversion to false.

It appears, however, that the ICC colour work has broken the implementation,
images in CMYK are not converted to RGB, because pdfwrite doesn't see them as
CMYK, it sees them as ICC. I'll open a new bug report for this and consult with
our colour expert later this week.