PHP code example of bdelespierre / php-phash
1. Go to this page and download the library: Download bdelespierre/php-phash 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/ */
bdelespierre / php-phash example snippets
use Bdelespierre\PhpPhash\PHash;
use Intervention\Image\ImageManager;
$manager = new ImageManager(['driver' => 'imagick']);
$phash = new PHash($manager);
$hash = $phash->hash(new \SplFileInfo("image.jpg"));
$bash_hex = base_convert($bits, 2, 16);
echo $base_hex; // ffffef0001900000
$hash1 = $phash->hash(new \SplFileInfo("image1.jpg"));
$hash2 = $phash->hash(new \SplFileInfo("image2.jpg"));
$dist = 0;
for ($i = 0; $i < $size ** 2; $i++) {
if ($hash1[$i] != $hash2[$i]) {
$dist++;
}
}
echo "Hamming distance is: {$dist}";
bash
composer