motniemtin / phash
Find similar images percent
dev-master
2019-05-02 22:51 UTC
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2025-03-29 00:42:08 UTC
README
sample code use Motniemtin/pHash/pHash; #sample implementation
$phasher = new pHash;
$phash2 = $phasher->getHash('phash2.jpg', false);
//this will echo hash in hex, then binary
echo $phasher->hashAsString($phash2, false).PHP_EOL;
echo $phasher->hashAsString($phash2).PHP_EOL;
$phash3 = $phasher->getHash('phash3.jpg', false);
//this will echo hash in hex, then binary
echo $phasher->hashAsString($phash3, false).PHP_EOL;
echo $phasher->hashAsString($phash3).PHP_EOL;
//using BIT COUNT METHOD FOR SIMILARITY
echo $phasher->getSimilarity($phash2, $phash3, 'BITS');
echo PHP_EOL;
//using HAMMING METHOD (DEFAULT) FOR SIMILARITY
echo $phasher->getSimilarity($phash2, $phash3);
echo PHP_EOL;