working png output from graphing modules

Tim Evans t.evans at
Wed Sep 24 11:18:20 CEST 2003

johnlichtenstein at (john) writes:

> Are there any charting or graphing modules for python that can write
> PNG, JPEG, or GIF graphics? I have found a couple of nice looking
> packages that can make beautiful postscript, PDF, or SVGs (PyChart and
> ReportLab) but they can't make PNGs, GIFs, or JPEGs. (On my Solaris
> machine with Python 2.2 they don't.) Or are there any simple UNIX
> filters to convert SVG, PDF, or ps files to PNG?

The 'convert' utility from ImageMagick (google for it) is very good at
converting PDF or PS to PNG.  It uses ghostscript to do the actual
conversion; it's just very good at choosing the right options to pass
to ghostscript.

convert -geometry 800x600 -density 200 foo.png 

Will convert a postscript to a png, keeping the aspect ratio correct
but making it fit inside an 800 by 600 pixel area.  The -density
argument tells it the dpi to use when rendering the image.  Higher
values are slower but give better results.

Tim Evans

More information about the Python-list mailing list