28 Jan

Finding image differences on Mac OS X

Finding the differences between two images can be quite tricky, especially if those differences are quite subtle. It’s easy to miss things with the human eye, and overlaying images in Photoshop and rapidly toggling between them only makes it slightly easier.

Luckily, ImageMagick gives us a free set of command line tools to do tasks like this for us. If you don’t have a copy, head over to Cactus Labs and pick up their free installer. It’s by far the easiest way of installing it.

I’m going to show you how to find the differences between two images using ImageMagick’s compare tool in the Terminal. I’m going to compare two versions of a graphic I have called “demo_image_v1.ai”, and “demo_image_v2.ai” and find out which pixels are different.

Source images to compare

First, launch your Terminal – you’ll find it in /Applications/Utilities. Next, type ‘compare’ into your Terminal., followed by a space. It should look something like this.


Next, drag the first image file into the Terminal. It should automatically fill in the path to the image file. I’m using an image called “demo_image_v1.ai”, which lives in a folder on my desktop called “demo_images”. Note how the path looks in the Terminal. Your path will be different, of course!


Next drag the second file into your Terminal. You should now have something that looks like this:


So, what we’ve done so far is tell ImageMagick’s compare tool to find the differences between the two files we dragged onto the Terminal. The last thing to do is to tell it where to save the results. Let’s put the results in a file on the Desktop named, “differences.jpg”. So, type a space in your Terminal and then type:


Just in case you’re not familiar with file paths in the Terminal, “~/Desktop” is shorthand for the path to the desktop.

Your Terminal window should now look something like this:

So, we’ve now told the compare tool about two files we want to compare, and given it a location to save the results to. Hit return in your Terminal to run the command.

If you’ve given compare two large images, there may be a bit of a pause. However, you should eventually get a file on your desktop named “differences.jpg” with the pixels which are different between the two images marked in red. Cool, eh?


This is just a simple example – there is much more to ImageMagick’s compare tool. For more options, head back to your Terminal and type “man compare” for the full manual.

Have fun!