Index ¦ Archives ¦ Atom ¦ RSS

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
ls
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 400x300), 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)

© Prashanth Ellina. Built using Pelican. Theme by Giulio Fidente on github.