[bug-gs] CMYK to RGB conversion with Ghostscript and Imagemagick

Ray Johnston ray.johnston@artifex.com
Wed, 23 Apr 2003 11:43:30 -0700


James,

James Lee wrote:
> 
> Hello!
> I am working on conversion PSD, EPS, PS files using Ghostscript and
> Imagemagick.When I convert a file (originally in CMYK) to RGB I am getting
> very bright and funny colors. I have search mailing list and it seems that
> I am not the one, who had this problem.

I assume you meant to say "I am not the only one, who had this problem."

Unless you do something to force colors to be converted, Ghostscript gives you
the 'default' CMYK to RGB conversion, along the lines of R = 1 - max(C,K)
G = 1 - max(M,K) and B = 1 - max(Y,K). This tends to make the colors seem
"brighter" than printed CMYK.

> Somebody thinks it is because Ghostscript supports 1 bit color.

That somebody is wrong. Ghostscript internally manages colors as 15-bit
fractions although conversion to RGB usually drops down to 8-bit.

> I tried even to use color profiles from www.littlesms.com but I still
> not able to get right colors.

You need to do two things to get Ghostscript to convert CMYK colors to
what you (probably) expect:

1) If you are running Ghostscript 8.00 or later check to make sure that
   the following patch to lib/gs_init.ps has been applied:

diff -c -r1.87 gs_init.ps
*** lib/gs_init.ps      12 Apr 2003 18:08:18 -0000      1.87
--- lib/gs_init.ps      23 Apr 2003 18:33:16 -0000
***************
*** 1749,1754 ****
--- 1749,1763 ----
  put                           % Policies in pagedevice
  .setpagedevice
  %END MEDIA
+
+ % Set up the interpreter context version of -dUSeCIEColor option
+ % so that .getuseciecolor has the correct value (see gs_setpd.ps)
+ /setpagedevice where {
+   pop systemdict /UseCIEColor known {
+     mark /UseCIEColor UseCIEColor .dicttomark setpagedevice
+   } if
+ } if
+
  %END DISPLAYING

  (END DEVICE) VMDEBUG

2) set the -dUseCIEColor command line option. This will cause CMYK colors
   to go through the /DefaultCMYK ColorSpace conversion (actually installs
   a CIEBasedDEFG colorspace).


Note that if you don't want to apply the patch, you could also use the
following slightly more verbose command line option:

    -c "<< /UseCIEColor true >> setpagedevice " -f 

just before the input file to be converted.

If you want an even better (SWOP) based DefaultCMYK colorspace conversion,
I can provide one.

Regards,
Ray Johnston
Artifex Software Inc.
_________________________________________________________________________