Marci-man
Marci-man

Reputation: 2233

comparing 2 images in PHP

I am aware that there is one more question like mine, but I just thought mine was after all a bit different.

I have to be able to establish if the images are very similar or entirely different...
have a look at the following two images:
lighter image darker image

The first image is a bit lighter than the second image. You can see that on black striped fish in the middle.

So, comparing the md5 hashes doesn't really help. Is there anyother clever way to do it?
thanks!

Upvotes: 7

Views: 2551

Answers (4)

Mian Anjum
Mian Anjum

Reputation: 379

Try this .Someone wrote open source code .

http://compareimages.nikhazy-dizajn.hu/

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.

Upvotes: 0

Mustafa
Mustafa

Reputation: 48

this way is useful

$img1 = md5(file_get_content($image1))
...
if($img1 == $img2){
..
}

Upvotes: 0

user3027057
user3027057

Reputation: 24

I am not sure if it would help, but I think if you run the images through GD image processing, it would really help you there!

Upvotes: 0

Tarek
Tarek

Reputation: 3798

try that function

http://www.php.net/manual/en/function.imagick-compareimages.php

you will need to google for usage since the doc seems to be empty ...

Upvotes: 3

Related Questions