ImageMagick

It seems counterintuitive at first to be using command-line programs to manipulate photographs and images. However, you begin to appreciate its benefits if you need to process dozens of image files in exactly the same way.

For example, what if you had a hundred image files and you needed to scale them down by 50%? If you were using a regular photo editor, you'd need to open a hundred files and individually scale them down. But if you had a single command to do them as a batch? Easy!

And that's what ImageMagick is for.

ImageMagick is a set of utilities for converting images. According to its man page:

It can read, convert and write images in a large variety of formats. Images can be cropped, colors can be changed, various effects can be applied, images can be rotated and combined, and text, lines, polygons, ellipses and Bezier curves can be added to images and stretched and rotated.


Sounds complicated? It's actually easier in practice.

First thing to do is install ImageMagick. It's an officially supported Ubuntu package, but it's not included in the base CD. To install,

sudo apt-get install imagemagick

ImageMagick comes with several utilities. The two that I most often use are convert and mogrify. Both have similar functions, but convert will output the manipulated image file into a new file while mogrify changes the image file itself.

Going back to the example earlier, then, how would you scale down by 50% a set of JPEG image files in a directory? Go into the directory and run the command

mogrify -scale 50%x50% *.jpg

Voila! The dimensions of all image files will then have been reduced by half.

ImageMagick is a real Swiss army knife of utilities. There's so much more that you can do with it. See the ImageMagick usage pages for more in-depth examples.