Check if 2 photos are visually the same in PHP - rest7/api GitHub Wiki
You can use this method to check whether two images are perceptually similar even when they have different file sizes, different resolutions or different image formats.
Comparing two images visually in PHP using free API:
<?php
$url1 = 'http://server.com/image.jpg';
$data1 = json_decode(file_get_contents('http://api.rest7.com/v1/visual_hash.php?url=' . $url1));
$url2 = 'http://server.com/image.png';
$data2 = json_decode(file_get_contents('http://api.rest7.com/v1/visual_hash.php?url=' . $url2));
if (@$data1->success !== 1 or @$data2->success !== 1)
{
die('Failed');
}
$hash1 = $data1->hash;
$hash2 = $data2->hash;
if ($hash1 == $hash2)
{
echo 'Images are identical';
}
else
{
echo 'Images are not identical';
}