Ubuntu – Use ImageMagick to compare Images

imagemagick

I want to compare a source png file to a compressed file.

I am using imagemagick and this command:

convert image1 image2 -compose Difference -composite \
       -colorspace gray -format '%[fx:mean*100]' info:

But what I get is a very odd number. I am looking from a number from 0-100%.

When I compared two totally different images I still get a 8.37885.

So good people of Ask Ubuntu, can you provide me with a command that will measure the difference between files properly and give me a number from 0-100?

Best Answer

The problem is with the colorspace gray part of the command. This option checks only difference between gray colour of the images.

So the correct command should be

convert image1 image2 -compose Difference -composite  -format '%[fx:mean*100]' info:

This should give you more appropriate answer.