Linux: Convert a PDF File To an Image

by on January 16, 2009 · 26 comments· LAST UPDATED January 16, 2009

in , ,

Q. A friend showed me how to extract images from a pdf file using pdfimages utility. But I'd like to convert my PDF file to image file. How do I convert a PDF to an image file using a command line option?

A. You need to use convert command from imagemagick - image manipulation set of programs.

The convert program is a member of the ImageMagick suite of tools. Use it to convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. This is also useful if you do not have PDF reader installed (Gnome and KDE does have in built PDF reader) or required for your webbased project.

Type the following command to convert foo.pdf to foo.png (foo1.png, foo2.png.. etc if you have multiple pages in a pdf file):
$ convert foo.pdf foo.png
You can specify a different file type by changing the file extension of the second file, type:
$ convert foo.pdf foo.jpg

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 26 comments… read them below or add one }

1 igor January 16, 2009 at 10:05 am

on debian/etch you need ghostscript (package: gs) for this operation.


2 ob1y2k January 16, 2009 at 11:13 am

hm, life saving command ^_^


3 divide_by_zero January 16, 2009 at 1:28 pm

Doesn’t the Gimp open PDF files?


4 Laurent GRÉGOIRE March 9, 2009 at 9:13 pm

Use “-density ” option for setting precision in points per inch, example:
$ convert -density 300 file.pdf image.png
By default the dpi is 72, which could be too low. Make sure the option is _before_ the filenames though.


5 linuxkasten August 1, 2011 at 1:00 pm

thank you very much!


6 Jose_X October 18, 2011 at 7:59 pm

I second that.. especially the part about “_before_ the filenames”


7 Robinson November 26, 2011 at 4:40 am

buenisimo…! =D Gracias


8 Marcus Wanner December 6, 2011 at 4:44 am

Thank you so much. I had no idea that putting the arguments in a different order would make a difference.


9 Perdu March 10, 2014 at 5:39 pm

Thanks a lot


10 Andrey August 31, 2014 at 11:13 am

thanks for useful parameter!


11 Jan M. November 13, 2014 at 8:14 am

Great, thanks.


12 Martin July 27, 2009 at 7:44 pm

Thanks Laurent, that density option was the command I was looking for. Now I can have image output at appropriate quality.


13 tsyma October 1, 2009 at 4:08 pm

on debian/lenny you need imagemagick(package: imagemagick) for this operation


14 Patrick EB June 21, 2010 at 3:06 am

Sometimes life is so easy :)

Convert pdf to png and back again with such ease.

Very nice :))


15 lali May 12, 2011 at 1:50 pm

i dont know why but this isnt working for me .
i have 2 Gb of free space and what this command does is reduce it to 4 KB .
No output file or anything is generated ..


16 hans December 27, 2011 at 12:27 pm

Thanks!! It was exactly what I was looking for!


17 Carl February 5, 2012 at 9:41 pm

Love ImageMagick for it’s neat feature to handle PDF (more or less as-is). Also, big thanks to Laurent for explaining the “-density” switch; which (until now) was the missing point in my latest workflow. Cheers!


18 Rolando February 7, 2012 at 3:08 pm

i dolwnoad eagle strike audio book and it came up as file so renamed it .mp3 still no work


19 Alastair February 10, 2012 at 11:20 am

“convert eagle-strike.pdf eagle-strike.mp3″ :P


20 Aripin February 10, 2012 at 6:27 am

Yes the trial can covrent to any of the formats, did you download the Standard trial or Pro?


21 Craig Owen February 12, 2012 at 8:08 pm

I’m trying to convert a 350 page pdf file (95MB). If I set the density to 72×72 it works perfectly but I can’t read the text. If I set the density to 150×150 it crashes out after page 3. I’m guessing that I’m running out of memory. Is there any way to specifiy the page number to start the conversion from?
Any help is appreciated


22 Alastair February 12, 2012 at 10:54 pm

Add -f 1 -l 10 for starting on the first page and ending on the tenth. You might need another tool to split it into smaller chunks first, though.


23 nrivoli May 27, 2012 at 11:52 pm

-depth 8 for lower size file


24 Dan June 28, 2013 at 7:27 am

im using convert command to a pdf with thai characters in it but when i do, the resulting file does not contain thai characters(it is replaced by empty characters) . Please advise.


25 Sanyogita Mande November 7, 2013 at 9:54 am

this “density” option really helps with the convert command :)
i am glad to get a good quality image post conversion
Thanks a lot


26 Katherine Dimacale September 17, 2014 at 11:23 pm

Thanks for this helpful guide. I’ll find it easier to convert my files to an image. Btw, if you want the other way around, you can also use this tool I just discovered it and it’s easy to use. Give it a try


Leave a Comment

Tagged as: , , , , , , , , , , , , ,

Previous Faq:

Next Faq: