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
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop












{ 20 comments… read them below or add one }
on debian/etch you need ghostscript (package: gs) for this operation.
hm, life saving command ^_^
Doesn’t the Gimp open PDF files?
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.
thank you very much!
I second that.. especially the part about “_before_ the filenames”
buenisimo…! =D Gracias
Thank you so much. I had no idea that putting the arguments in a different order would make a difference.
Thanks Laurent, that density option was the command I was looking for. Now I can have image output at appropriate quality.
on debian/lenny you need imagemagick(package: imagemagick) for this operation
Sometimes life is so easy :)
Convert pdf to png and back again with such ease.
Very nice :))
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 ..
Thanks!! It was exactly what I was looking for!
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!
i dolwnoad eagle strike audio book and it came up as file so renamed it .mp3 still no work
“convert eagle-strike.pdf eagle-strike.mp3″ :P
Yes the trial can covrent to any of the formats, did you download the Standard trial or Pro?
Hi,
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
Craig
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.
-depth 8 for lower size file