Creating thumbnails at the command line

Really simple stupid using the ImageMagick package, as long as you have a real command line to work with.

First make sure ImageMagick is installed.

yum install ImageMagick

Then figure out how big you want your thumbnails to be. In my case, nominally 80px by 80px from (very roughly) 350px by 350px originals. Use the convert utility to generate your thumbnails.

convert -thumbnail 80 somepic.jpg somethumb.jpg

The lone “80” refers to 80px in width, allowing the util to adjust height dynamically. In my real situation many of the images were somewhat longer in height than wide (for example, 350x466px), making for a slightly longer thumbnail (in the case of a 350x466px original resulting in a 80x107px thumbnail).

The convert utility has lots of other options for manipulating images, and the ImageMagick collection it is part of has many more utilities along the same lines.

For those who want to go beyond the shell, there are ImageMagick APIs for perl (via the Image::Magick module), python, php and other scripting languages.

This entry was posted in Development, System Administration, Web on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).