Compare Images PHP Class

This PHP Class compares two images and returns a number representing how similar they are. It is capable to tell if two pictures are similar even if they have different sizes or aspect ratio. Smaller number means the images are more similar. Numbers more than 10 means they are most likely not the same image.

Example #1: Different size. Number you get: 2

Example #2: Different size. And aspect ratio. Number you get: 4

Example #3: Different light and contrast. Number you get: 1

Example #4: Exactly the same image. Number you get: 0

Example #5: Completely different image. Number you get: 25

Try it!

(copy image URLs here or click on the images above to put their URL in the fields below. The clicks alternately change the value of the fields.)

The Code

It is simple, but I wrote it on the fly so I am sure it can be more simple than this. Feel free to change whatever you want and use it as you like. Please mention me somewhere if you use it :). It is easy to add gif support for example. (I didn't do it, because I would like to compare animations too... and that would be too much here.)

Created by Ákos Nikházy © 2013