Dr. Ivan's Blog Medicine Art and Design Programming Music

Recent posts:


Art (3)
Computer (24)
Education & Specialization (2)
Medicine (4)
Music (8)
This Site (2)

WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.


28.06.09 | Tips & Tricks: Converting PDF-s to pictures in Linux
Filed under: Computer — Tags: , , — Dr. Ivan @ 21:54 — Comments (10)

Ever wondered how to render PDF-s into individual pictures page by page? It is really simple.

Warning to all of those who are allergic to command line: The following method does imply use (albeit very simple) of CLI.

Here we will be using a tool called ImageMagick. This is a widely available tool with unparalleled versatility in a variety of areas, but is by no means the only one: there are plenty of other tools to do the same thing. The following is only one method of many.

1) So first of all you will need to install ImageMagick. In Ubuntu you would do:

sudo apt-get install imagemagick

2) Then open up a terminal, and browse to the location of the PDF you want to convert. Say, if your PDF was in /home/username/PDFs, you would do the following:

cd /home/username/PDFs

3) Let’s say that you have a PDF file called test.pdf and you want it to convert to PNG files. You also want these PNG files’ filename to begin page. Then you would run:

convert test.pdf page.png

This will give you as many PNG files named page-01.png, page-02.png, … as there are pages in your original PDF.

If you wanted JPEG files instead just run:

convert test.pdf page.jpg

You might also want to control the resolution of the resulting image files. To do that you must specify the -density option. It is hard to predict what number you should give, so try to experiment to get the desired result. If you wanted a density of, say, 800, you would run:

convert -density 800 test.pdf page.png

Want to select certain pages only? No problem, to convert only the first page – run:

convert "test.pdf[0]" page.png

You may also specify a range. So to convert the first three pages run:

convert "test.pdf[0-2]" page.png

Several ranges are also possible:

convert "test.pdf[0-2,4-6]" page.png

(Note that the output files will be consecutively named in the latter example, so you will get files page-0.png, -1, -2, -3, -4 and -5.png. NOT as you would expect page-0.png, -1, -2, -4, -5 and -6)

Edit: If you are inclined to use another conversion utility, try pdftoppm from the package poppler-utils. Works very well, too…

That’s really it!
Hope you found this useful!

FacebookStumbleUponTwitterBlogger PostRedditGoogle BookmarksDZoneDeliciousDiggHotmailMySpaceCiteULikeYahoo BookmarksWebnewsTumblrSlashdotShare


  1. avatar

    [...] of memory” error messages will make frequent appearances. In the end, you will be better off converting your more advanced pdf-s into pictures and viewing them page by [...]

    Pingback by Nokia N95 8GB – My Review After One Year’s Use « Dr. Ivan's Blog — 28/06/2009 @ 21:55

  2. avatar

    GIMP also opens PDF files and saves them as pictures (JPG). Since it is usually installed by default on most LINUX installations, you don’t actually need to load anything else

    Comment by Howard — 06/07/2009 @ 07:26

  3. avatar

    ImageMagick ftw! I always forget about this when I want to do image/pdf manipulation… Oh and funky tag-cloud plugin…

    Comment by TGM — 06/07/2009 @ 08:42

  4. avatar


    Gscreendump can help you with that task.
    Just drag & drop a PDF file to it and it will handle the rest.

    Installation instructions

    There’s also a video that shows this PDF splitting thing.

    Watch and enjoy ;-)

    Comment by Moma Antero — 06/07/2009 @ 09:44

  5. avatar

    Thank you all for your comments!

    @Howard: Absolutely! Although AFAIK the different pages are imported as separate layers, so you will have to save them one by one manually. Although I am sure someone has already made a script to take care of it automatically.

    @TGM: Yes, indeed, it is very handy. And it has a lot of other neat features which makes it perfect for usage in scripts of all sorts. edit: The cloud plug-in is called WP-Cumulus btw :)

    @Moma Antero: Haven’t heard of it until now, but your app looks really handy! Thank you very much for posting it here – I’m sure it will be well-suited for those who want a GUI frontend!

    Comment by Dr. Ivan — 06/07/2009 @ 17:04

  6. avatar

    Just wanted to drop you a line to say, I enjoy reading your site. I thought about starting a blog myself but don’t have the time.
    Oh well maybe one day…. :)

    Comment by Donnieboy — 12/10/2009 @ 19:54

  7. avatar

    4Videosoft PDF to Image Converter is a quick tool that converts your PDF documents to various image formats in batch mode.


    Comment by vl — 15/04/2011 @ 15:27

  8. avatar

    Really appreciate you sharing this post. Want more.

    Comment by Chris Navarrete — 20/04/2012 @ 02:04

  9. avatar

    Dr Ivan, Thanks very much. The code below was what I exactly needed! Cheers :)

    Want to select certain pages only? No problem, to convert only the first page – run:

    convert “test.pdf[0]” page.png

    Comment by Chandra — 02/10/2012 @ 08:24

  10. avatar

    Hi Chandra! Thank you for reading and commenting!


    Comment by Dr. Ivan — 03/10/2012 @ 17:33

RSS feed for comments on this post. TrackBack URL

Leave a comment