There was an error in this gadget


Tuesday, May 20, 2008

Converting PDF to PNG/JPG using ImageMagick in Linux

Being an undergrad student a lot of the lecture notes and study related material i have is in PDF format now a lot of times i have felt the need of carrying this material around, however carrying laptop around all the time is just not feasible.I have a Video Ipod that could store images and one could view them on the go however it cannot display pdf files so my search began for a tool that could actually convert PDF files into PNG that could be later loaded on to the ipod and viewed at one's convenience .

Note : The installation instruction below are for Ubuntu however they should work perfectly well on any other distro as long as you have ImageMagik and Ghost Script installed.

Installing ImageMagick
ImageMagick is a powerful command line image processing package with a number of features you could install it using the following command :

sudo apt-get install imagemagick
After installation is over to convert say sample.pdf to sample.png issue the following command

convert sample.pdf sample.png

convert sample.pdf sample.jpg

Now if sample.pdf has multiple pages ImageMagick would convert each individual page into a separate file for example : 1st page as sample-0.png , 2nd page as sample-1.png and so on .

However ImageMagick internally uses Ghostscript to convert the file to graphics image so resolution might be bit less and if you want to convert document into higher resolution image you could do so by using Ghostscript directly.

There are number of options available in convert which you could inquire by issuing convert -? command.

Article Written by : Ambuj Varshney (
For Desktop on Linux Blog ,
(C) 2008 , Ambuj Varshney


Agus Susanto said...

Hi there,
I have 32 pages of pdf file and I want to convert it into png format with 4 images per page. Please show me how to do it. Thanks.

Anonymous said...

Print those 32 pages as another PDF with 4 pages per page, first. Then use imagemagick.

Kuranes said...

For the quality, just play around with the -density switch
$ convert -density 300 sample.pdf sample.png

Anonymous said...


Anonymous said...

Thanks! The density switch is exactly what I needed!

illari said...

> I have 32 pages of pdf file and I want to convert it into png format with 4 images per page.

convert sample.pdf _.jpg
montage *.jpg -mode Concatenate -tile 4x1 line.jpg

eldelascanicas said...

so useful, thx a lot!

Post a Comment