Friday, January 30, 2009

Converting PDF files to images

This is easily done in Linux using ImageMagick. This application provides a command-line tool to convert between images formats. However, you can use it to convert a PDF file to an image file like a JPEG. ImageMagick seems to use Ghostscript for this purpose. See thread at

http://www.usenet-forums.com/php-language/35516-convert-pdf-image-format-imagemagick.html

To convert input.pdf to output.jpg use:

convert -density 300 input.pdf output.jpg

The argument 'density' specifies the resolution of the output file. 300 can be used for most purposes. The units are DPI. If you don't specify a density, the default (72) will be used. You can either specify the density as HORIZONTAL (like in this example to preserve aspect ratio) or HORIZONTALxVERTICAL.

You might experiment with different options of the convert command. The full documentation for this command is at

http://www.imagemagick.org/script/convert.php

1 comment: