2017 © Pedro Peláez
 

library image-hash

image

kodus/image-hash

  • Tuesday, June 27, 2017
  • by mindplay.dk
  • Repository
  • 4 Watchers
  • 4 Stars
  • 31 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 29 % Grown

The README.md

kodus/image-hash

This library implements the aHash, dHash and pHash image-hashing algorithms as described in this article., (*1)

It's based on this implementation but with a loader-abstraction for GD and Imagick support, added tests, and a benchmark., (*2)

Usage

To compare two images:, (*3)

use Kodus\ImageHash\ImageHasher;

$hasher = new ImageHasher();

$a_hash = $hasher->pHash("path/to/image-a.jpg");
$b_hash = $hasher->pHash("path/to/image-b.jpg");

if ($hasher->getDistance($a_hash, $b_hash) <= 2) {
    echo "same!";
} else {
    echo "different.";
}

Substitute calls to pHash() for aHash() or dHash() to use another algorithm, but note that getDistance() only makes sense for two hashes computed using the same algorithm., (*4)

Hashes are returned as a binary-mask string - use base_convert if you need a decimal or hex value., (*5)

Hacking

To run the tests:, (*6)

php test/test.php

To run the benchmark:, (*7)

php test/benchmark.php

If you hack on this library, be sure to run the benchmark before/after making changes., (*8)

The Versions

27/06 2017

dev-master

9999999-dev

  Sources   Download

The Development Requires

27/06 2017

0.1.0

0.1.0.0

  Sources   Download

The Development Requires