Bug 693169 - Can't convert RGB PDF to CMYK PDF with transparent image
Summary: Can't convert RGB PDF to CMYK PDF with transparent image
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Writer (show other bugs)
Version: 9.05
Hardware: PC Windows 7
: P4 enhancement
Assignee: Ken Sharp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-04 09:16 UTC by Md. Sufian Saory
Modified: 2014-03-22 02:01 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
RGB pdf contins two transparent image of butterfly in first page (2.94 MB, application/pdf)
2012-07-04 09:24 UTC, Md. Sufian Saory
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Md. Sufian Saory 2012-07-04 09:16:05 UTC
Hi,

I'm using Ghostscript 9.05 to convert RGB pdf to CMYK pdf. It's converting fine as long as the RGB pdf doesn't contain any transparent image. But with transparent image conversion does fail. Followings are the used parameter and error output

gswin64c.exe -o "out.pdf" -dNOPAUSE -dBATCH -dSAFER -sDEVIC
E=pdfwrite -dUseCIEColor -dPDFSETTINGS=/prepress  -sProcessColorModel=DeviceCMYK
 -sColorConversionStrategy=CMYK -sColorConversionStrategyForImages=CMYK "in.pdf"

GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 2.
Page 1
Error: /rangecheck in --.begintransparencygroup--
Operand stack:
   --dict:7/16(L)--   --dict:3/3(L)--   0   0   432   288
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval-
-   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   fa
lse   1   %stopped_push   1926   1   3   %oparray_pop   1925   1   3   %oparray_
pop   1909   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1
2   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--
  false   1   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1175/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:82
/200(L)--   --dict:109/127(ro)(G)--   --dict:291/300(ro)(G)--   --dict:24/31(L)-
-   --dict:6/8(L)--   --dict:21/40(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.05: Unrecoverable error, exit code 1



However if I use -dNOTRANSPARENCY flag it can convert to CMYK but the quality of the transparent image is unaccaptable.
Comment 1 Md. Sufian Saory 2012-07-04 09:24:54 UTC
Created attachment 8730 [details]
RGB pdf contins two transparent image of butterfly in first page

This PDF of two page contains two transparent butterfly image in first page. when converting to CMYK color pdf the conversion is failing.
Comment 2 Ken Sharp 2012-07-04 12:06:17 UTC
(In reply to comment #1)
> Created an attachment (id=8730) [details]
> RGB pdf contins two transparent image of butterfly in first page
> 
> This PDF of two page contains two transparent butterfly image in first page.
> when converting to CMYK color pdf the conversion is failing.

The problem is that you are setting -dUseCIEColor, the code is unable to convert a CIEABC color space into a DeviceCMYK space.

The current code (not the latest release, but the latest code in the Git repository) will emit a warning and alter the conversion strategy to 'leave color unchanged'. This will result in the images being emitted in an ICCBased colour space.

This is not a bug, the code is behaving as expected. At some point we intend to rewrite the colour handling in pdfwrite and this will be addressed at that time.
Comment 3 Md. Sufian Saory 2012-07-04 12:41:40 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > Created an attachment (id=8730) [details] [details]
> > RGB pdf contins two transparent image of butterfly in first page
> > 
> > This PDF of two page contains two transparent butterfly image in first page.
> > when converting to CMYK color pdf the conversion is failing.
> 
> The problem is that you are setting -dUseCIEColor, the code is unable to
> convert a CIEABC color space into a DeviceCMYK space.
> 
> The current code (not the latest release, but the latest code in the Git
> repository) will emit a warning and alter the conversion strategy to 'leave
> color unchanged'. This will result in the images being emitted in an ICCBased
> colour space.
> 
> This is not a bug, the code is behaving as expected. At some point we intend to
> rewrite the colour handling in pdfwrite and this will be addressed at that
> time.

Thanks you very much. After removing -dUseCIEColor flag conversion is working well. One thing if you can give me some solution I will really appreciate it, during color conversion transparent PNGs with shadow is loosing quality on shadow. Is there anything I'm missing.

Thanks in advance.
Comment 4 Ken Sharp 2012-07-04 12:55:39 UTC
(In reply to comment #3)

> Thanks you very much. After removing -dUseCIEColor flag conversion is working
> well. One thing if you can give me some solution I will really appreciate it,
> during color conversion transparent PNGs with shadow is loosing quality on
> shadow. Is there anything I'm missing.

I don't know what you mean by 'losing quality', but its probably some kind of over-aggressive downsampling or lossy image compression. If you remove -dPDFSETTINGS=/prepress does it make any difference ?

I would suggest that you start with the simplest possible command line and add or alter settings one by one, in general the simplest possible command line to pdfwrite will produce the best quality result, but not the smallest possible file.
Comment 5 Md. Sufian Saory 2012-07-04 13:02:34 UTC
(In reply to comment #4)
> I don't know what you mean by 'losing quality', but its probably some kind of
> over-aggressive downsampling or lossy image compression. If you remove
> -dPDFSETTINGS=/prepress does it make any difference ?
> 
> I would suggest that you start with the simplest possible command line and add
> or alter settings one by one, in general the simplest possible command line to
> pdfwrite will produce the best quality result, but not the smallest possible
> file.

Yes, without -dPDFSETTINGS=/prepress flag converted pdf's image is getting very lossy. I'm going to try out smallest command possible. Thanks.
Comment 6 Ken Sharp 2014-03-22 02:01:10 UTC
With the release of 9.12 this is now resolved. It is no longer necessary (and is now deprecated) to use -dUseCIEColor with pdfwrite in order to do colour management. It is also no longer necessary to set both ProcessColoModel and ColorConversionStrategy when going to a device space, the action of setting ColorConversionStrategy to a device space automatically sets ProcessColorModel to that space.