Compare 2 images in php

Most of the other answers refer to using various hashing functions. The question explicitly is asking about comparing the contents of the images, not about comparing the files.

This means you end up having to actually understand the contents of the image. In PHP there are two extensions often used for this, ImageMagick and GD.

ImageMagick offers various tools you can use for this, through the PHP ImageMagick extension.

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

Biggest problem is that the documentation for that library is pretty much non-existing, so there will be a lot of trial-and-error involved. The PHP extension is a pretty thin wrapper around the ImageMagick library, so details of how the compareimages() function behaves can be found in the ImageMagick documentation.

Leave a Comment