Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

You can compare two text files very easy with diff and even better with meld:

example meld

If you use diff for images, you get an example like this:

$ diff zivi-besch.tif zivildienst.tif 
Binary files zivi-besch.tif and zivildienst.tif differ

Here is an example:

Original from http://commons.wikimedia.org/wiki/File:Tux.svg

Original image



I've added a white background to both images and applied GIMPs "Difference" filter to get this:


It is a very simple method how a diff could work, but I can imagine much better (and more complicated) ones.

Do you know a program which works for images like meld does for texts?

(If a program existed that could give a percentage (0% the same image - 100% the same image) I would also be interested in it, but I am looking for one that gives me visual hints where differences are.)

share|improve this question
It appears you are linking to an SVG image. It is actually valid XML text. The same does not go for other image formats. –  hexafraction Oct 30 '12 at 11:30

1 Answer 1

up vote 16 down vote accepted

Yes, such a program exists!

ImageMagick has the compare utility, which has several ways of comparing images.

To install it:

sudo apt-get install imagemagick imagemagick-doc

Comparing two images visually:

compare -compose src tux_orig.png tux_modified.png tux_difference.png

tux_orig.png & tux_modified.png

tux_orig.png tux_modified.png

Gives this image:

The image difference

Comparing two images via metrics:

There are also many ways to output the differences via some metrics, e.g.:

# compare -verbose -metric PSNR tux_orig.png tux_modified.png tux_difference.png
tux_orig.png PNG 200x232 200x232+0+0 8-bit sRGB 20.6KB 0.000u 0:00.000
tux_modified.png PNG 200x232 200x232+0+0 8-bit sRGB 22.2KB 0.010u 0:00.000
Image: tux_orig.png
  Channel distortion: PSNR
    red: 19.5485
    green: 19.5973
    blue: 19.6507
    alpha: 16.1568
    all: 18.4517
tux_orig.png=>tux_difference.png PNG 200x232 200x232+0+0 8-bit sRGB 12.3KB 0.030u 0:00.020

Some metric options:

AE     absolute error count, number of different pixels (-fuzz effected)
FUZZ   mean color distance
MAE    mean absolute error (normalized), average channel error distance
MEPP   mean error per pixel (normalized mean error, normalized peak error)
MSE    mean error squared, average of the channel error squared
NCC    normalized cross correlation
PAE    peak absolute (normalize peak absolute)
PSNR   peak signal to noise ratio
RMSE   root mean squared (normalized root mean squared)

There are many ways to compare images, see ImageMagicks section on compare for further methods.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.