Image processing with ImageMagick

ImageMagick is incredibly useful software. This page will be used to collect examples of interesting things you can do with it.

Comparing a magnified section of two (or more) images

Imagine you want to illustrate the effect of JPEG compression, or some sort of image filter such as sharpening. It can be useful to crop out an equivalent section of two different versions of an image, and maybe magnify that section to make the difference clearer.

For example, the marked section in the following image:

The ship Aurora Australis in port

This can all be done in one command line:

montage -crop 250x250+1200+1600 -resize 500x500 -label '%f %b %G %Q%%' myImage99pc.jpg myImage60pc.jpg myImageCompare.png

This example assumes you saved two versions of your image to test 99% versus 60% JPEG compression quality. This command crops out a 250x250 pixel segment of each image, starting at the location 1200,1600. It then resizes this to 500x500 pixels (a 200% magnification) to more clearly show the differences.

The -label parameter labels each image segment with its file name, file size, dimensions (before resizing) and JPEG quality. The two image segments are then joined together into a single image and saved to a PNG file. A PNG file is used so that we don’t introduce more image compression artefacts into our comparison image.

A comparison of a magnified section of the Aurora image, showing 60% JPEG is significantly more blurry thatn 99% JPEG