Create PDF thumbnails using ImageMagick on Linux

imagemagick logoI have a bunch of PDF files for which I wanted to generate thumbnails. On looking around a bit, I found “ImageMagick“. Since I have Ubuntu installed, I did

sudo apt-get install imagemagick

It is not too big a download at around 740KB.

To create a thumbnails for all pages in the PDF document (say test.pdf which has 3 pages), do

convert -thumbnail x300 test.pdf test.png
> test.pdf test-0.png test-1.png test-2.png

The “x300″ tells the “convert” tool to keep the height at 300 pixels and modify the width to suit the height. If you have absolute dimensions in mind (say 400×300), do

convert -thumbnail 400x300 test.pdf test.png

If you want to control the width and have the height suited, do

convert -thumbnail 400 test.pdf test.png

What do you do if you want only the first page’s thumbnail? do,

convert -thumbnail x300 test.pdf[0] test.png

A neat feature of the “convert” tool is creation of animated gif’s having all the pages from the PDF document. do,

convert -thumbnail x300 test.pdf test.gif

“convert” is smart enough to figure out the output format from the file extension you provide in the arguments.

Nifty tools like “convert” from the ImageMagick suite are one of the reasons I love Linux! (ImageMagick is cross-platform, I’m referring the to utility of command-line tools and the UNIX philosophy of specialized tools that do one task really well)

2 Trackbacks

  1. By PDF e Imagemagick: creare miniature | Imola Blog on November 21, 2008 at 3:01 pm

    [...] a Prashanth Ellina « Aggiungere etichetta di testo ai [...]

  2. [...] is how to make a thumbnail of a pdf you will need to install ImageMagick and then [...]


  1. It works in Windows too.
    For animated gifs you can set the delay between frames with the delay parameter (in hundredths of a second):
    convert -thumbnail x300 -delay 100 test.pdf test.gif

    Massimo Santis last blog post..Aggiungere etichetta di testo ai PDF

    Posted November 20, 2008 at 8:02 pm | Permalink
  2. Is there are way to :
    1) Get all the pages of the PDF or some info ?
    2) How to specify the page e.g. thumbnail out of page 5 ?

    Slavis last blog post..Learning English with Youtube

    Posted February 27, 2009 at 8:08 pm | Permalink
  3. jabb

    try to put name.pdf[n] for n page.

    Posted April 7, 2009 at 7:43 pm | Permalink
  4. Dont forget, this runns only when GhostScript is installed.
    And my Question ist, how to convert only on special Page in a PDF-Document…?
    Whats the parameter ??

    thx Tom from Vienna…


    Posted June 12, 2009 at 11:27 pm | Permalink
  5. Boris

    to convert just a single page simply add [] to the filename. Just like:
    convert -thumbnail 400 test.pdf[0] test.png
    for the first page.

    Posted November 24, 2009 at 8:32 pm | Permalink