PHP code example of krugozor / hash

1. Go to this page and download the library: Download krugozor/hash library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

krugozor / hash example snippets




$hash1 = AverageHash::getHash('1.jpg');
$hash2 = AverageHash::getHash('2.jpg');

echo "Difference between $hash1 and $hash2: " . AverageHash::compare($hash1, $hash2);
// difference = 15

$hash3 = AverageHash::getHash('3.jpg');

echo "Difference between $hash1 and $hash3: " . AverageHash::compare($hash1, $hash3);
// difference = 10
// if different rates <= 10 then the images are duplicate