Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ghostscript converting Postscript to PNG is over-saturated

I'm trying to use Ghostscript and/or ImageMagick to convert each page of a Postscript document into PNG images. The problem is that both produce images that are way too saturated (I think that's the right terminology).

Here are the commands I'm trying:

gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 -sOutputFile=page_%02d.png brochure.ps
convert brochure.ps im_page_%02d.png

This is the input Postscript file (brochure.ps from above)

Here's a couple of the output images I'm getting:

Page 1

Page 6

As you can see (especially on the page with the big green map of New Hampshire), the colors of the output PNGs are too bright/saturated. How can I prevent the colors from being changed so much and get a more accurate conversion?

Preview in OS X 10.6 automatically does a very accurate conversion to PNG when you open a Postscript file in it. This leads me to believe there is just something screwy with the way ghostscript converts ps->png (I'm fairly confident ImageMagick is just a wrapper for ghostscript for this operation). Is there a tool besides ghostscript I should be using instead?

Note: As pipitas points out below, the visible difference of colors varies by OS. It is very obvious in OS X 10.6, but apparently not very noticeable in Windows XP.

like image 497
mateolargo Avatar asked Nov 14 '22 08:11

mateolargo


1 Answers

You are right in assuming ImageMagick just being a wrapper for Ghostscript when converting from PostScript or PDF to an image format.

I think, this problem can only be solved to anybody's satisfaction once the efforts to add support for ICC profile handling and color management (currently underway) are completed for Ghostscript (design document as PDF). That point in time is close, however. If I understand recent commits to http://svn.ghostscript.com/trunk/ correctly, the next release (which will be dubbed 9.00 and out hopefully in August) will include support for color management via LittleCMS. Yay!

like image 132
Kurt Pfeifle Avatar answered Dec 04 '22 21:12

Kurt Pfeifle