How to convert Postscript or PDF images into PNG format.
Artwork
For artwork that is transparent in undrawn-upon areas:
gs -dSAFTER -dBATCH -dNOPAUSE -sDEVICE=pngalpha \
-dBackgroundColor='16#ffeebb' \
-sOutputFile=output.png input.eps
The
-BackgroundColor='16#ffeebb' option sets the fall-back background color in the resulting PNG image to match the background color of the Community Projects site. This is needed by browsers that don't properly support PNG alpha transparency, (i.e., Internet Explorer), which will otherwise render the image horribly.
If the page size isn't specified in the document that you're converting, you may need to set it manually by adding the options
-dDEVICEWIDTHPOINTS=w -dDEVICEHEIGHTPOINTS=h; otherwise, your resulting PNG file may be the size of a default sheet, typically U.S. letter.
If your input document is in EPS format, the
-dEPSCrop option will set the correct size automatically. Otherwise, the correct values for
w and
h can often be determined from the bounding-box comments in the input document, which can be retrieved as follows:
gs -dSAFTER -dBATCH -dNOPAUSE -sDEVICE=bbox input.ps
Then just pick out the right and bottom coordinates from the output:
%%BoundingBox: 8 13 487 499
%%HiResBoundingBox: 8.424000 13.626000 486.953985 498.559968
In this example,
w=487 and
h=499.
Ref:
http://www.cs.wisc.edu/~ghost/doc/cvs/Devices.htm#PNG
Thumbnails of PDF-based presentations
gs -dSAFTER -dBATCH -dNOPAUSE -sDEVICE=png16m \
-dGraphicsAlphaBits=4 -dTextAlphaBits=4 \
-dBackgroundColor='16#ffeebb' -r45 \
-sOutputFile=LectroTestTalk-%02d.png \
-dFirstPage=1 -dLastPage=1 ../pgh-pm-talk-lectrotest.pdf
The
-r45 flag tells ghostscript to use a 45-ppi rendering resolution.