Page 1 of 1

Strange grey squares when viewing postscript file

Posted: 2009-03-10T07:15:04-07:00
by ajheaps
I originally posted this problem to the users list on Tue Feb 17, 2009 2:41 am. The problem was that ImageMagick 6.4.3 produces strange grey squares on the plot when using the display command on a postscript file. This is the case on OpenSuse 11.1 32 and 64 bit systems. The snapshot of the screen (test.png), original postscript file (idl.ps) and output PNG file (idl.png) can be seen at:
http://ncas-climate.nerc.ac.uk/ajh/imagemagick

The problem is that ImageMagick 6.4.3 calls gs with "-sDEVICE=pngalpha" rather than "-sDEVICE=pnmraw" which is the case with ImageMagick 6.3.5. The following code is slightly modified to show the problem.

This is what is executed when doing display idl.ps on ImageMagick 6.4.3:
"gs" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 \
-dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pngalpha" -dTextAlphaBits=4 \
-dGraphicsAlphaBits=4 "-r89.9986x89.9986" -g744x1051 \
"-sOutputFile=idl.png" "-fidl.ps"

This is what is executed when doing display idl.ps on ImageMagick 6.3.5:
"gs" -q -dQUIET -dSAFER -dPARANOIDSAFE -dBATCH -dNOPAUSE -dNOPROMPT \
-dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pnmraw" \
-dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r89.9986x89.9986" "-g744x1051" \
"-r89.9986x89.9986" "-sOutputFile=idl2.png" "-fidl.ps"

When I execute the above commands on an OpenSuse 10.3 or 11.1 system (ImageMagick 6.3.5 and ImageMagick 6.4.3 respectively) I get:
strange grey squares when using display idl.png ("-sDEVICE=pngalpha")
a normal white background when using display idl2.png ("-sDEVICE=pnmraw")


Is this a bug or a feature? Is there a flag I can set on ImageMagick 6.4.3 to use pnmraw rather than pngalpha when using display command on postscript files?

Best Regards
Andy

Re: Strange grey squares when viewing postscript file

Posted: 2009-03-10T10:09:34-07:00
by magick
Try this command:
  • convert -density 400 idl.ps -resize 25% idl.png

Re: Strange grey squares when viewing postscript file

Posted: 2009-03-11T02:24:54-07:00
by ajheaps
On OpenSuse 11.1 which uses ImageMagick 6.4.3 I get:

convert -verbose -density 400 idl.ps -resize 25% idl.png
"gs" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r400x400" -g3306x4672 "-sOutputFile=/tmp/magick-XXiSQr2Z" "-f/tmp/magick-XX4OaSrh" "-f/tmp/magick-XX23srRy"
/tmp/magick-XXiSQr2Z PNG 3306x4672 3306x4672+0+0 8-bit DirectClass 1.577mb 0.730u 0:02
idl.ps PS 3306x4672 3306x4672+0+0 16-bit DirectClass 1.577mb
idl.ps=>idl.png PS 3306x4672=>827x1168 827x1168+0+0 16-bit DirectClass 592kb 1.010u 0:02

When I use display idl.png I see the same strange grey sqaures as before.

The problem is that the device used is pngalpha. In OpenSuse 10.3 which uses ImageMagick 6.3.5 the device used is pnmraw which gives the correct image with a white background.

Re: Strange grey squares when viewing postscript file

Posted: 2009-03-11T05:35:44-07:00
by magick
We got the same squares when using the pnmraw device and only rendering at the higher resolution did the squares disappear. The pnmraw device does not support transparency so if that's not a problem you can edit the delegate.xml file to change the ps:alpha delegate to use pnmraw rather than pngalpha. If you cannot edit the system installed delegate.xml file, you can introduce your changes in a file at ~/.magick/delegate.xml. For security reasons, some configuration files cannot be over-ridden so test delegate.xml and see it works. Of course you can install your own version of ImageMagick in your home directory to resolve the problem.

Re: Strange grey squares when viewing postscript file

Posted: 2009-03-11T06:31:58-07:00
by ajheaps
Many thanks - that did the trick! I edited the system delegates.xml file and replaced pngalpha with pnmraw and I now see a white background on all my plots.

Best Regards
Andy