2017 © Pedro Peláez
 

library image-perceptualhash

travail/image-perceptualhash

image

travail/image-perceptualhash

travail/image-perceptualhash

  • Sunday, September 24, 2017
  • by travail
  • Repository
  • 4 Watchers
  • 8 Stars
  • 382 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 3 Versions
  • 11 % Grown

The README.md

Image\PerceptualHash

NAME

Image\PerceptualHash - Generate comparable hash from images, (*1)

SYNOPSIS

<?php

use Image\PerceptualHash;
use Image\PerceptualHash\Algorithm\DifferenceHash;
use Image\PerceptualHash\Algorithm\PerceptionHash;

// Create an instance of Image\PerceptualHash, at the same time calculate hashes
// using hashing algorithm Image\PerceptualHash\Algorithm\AverageHash by default
$ph = new PerceptualHash('/path/to/foo.jpg');

// Get binary hash
$binary_hash = $ph->bin();

// Get hexadecimal hash
$hex_hash = $ph->hex();

// Compare with another image, return a Hamming distance
$distance = $ph->compare('/path/to/bar.jpg');

// Calculate a similarity
$similarity = $ph->similarity('/path/to/baz.jpg');

// Calculate by other hashing algorithms
$ph = new PerceptualHash('/path/to/foo.jpg', new DifferenceHash());
// or
$ph = new PerceptualHash('/path/to/foo.jpg', new PerceptionHash());

DESCRIPTION

Image\PerceptualHash generates distinct, but not unique fingerprint with three hashing algorithms. Unlike cryptographic hashing, these fingerprints from similar images will be also similar., (*2)

DEPENDENCIES

  • ext-gd

INSTALLATION

To install this package into your project via composer, add the following snippet to your composer.json. Then run composer install., (*3)

"require": {
  "travail/image-perceptualhash": "dev-master"
}

or, (*4)

"repositories": {
  {
    "type": "vcs",
    "url": "git@github.com:travail/php-Image-PerceptualHash.git"
  }
}

TESTS

After cloning the project, run composer install and ./vendor/bin/phpunit., (*5)

$ git clone git@github.com:travail/php-Image-PerceptualHash.git
$ cd php-Image-PerceptualHash
$ composer install
$ ./vendor/bin/phpunit

METHODS

__construct

Image\PerceptualHash __construct($file, Algorithm $algorithm)

Creates a new instance of Image\PerceptualHash and calculates hashes., (*6)

$file

Path to a file or a resource of that., (*7)

Algorithm $algorithm

Hashing algorithm, currently the following algorithm are available:, (*8)

  • AverageHash
  • DifferenceHash
  • PerceptionHash

bin

string bin()

Returns calculated binary hash., (*9)

hex

string hex()

Returns calculated hexadecimal hash., (*10)

compare

int compare(string|resource $file)

Compares with another image and returns the Hamming distance to that., (*11)

$file

Path to a file or a resource of that., (*12)

distance

int distance(string $hash1, string $hash2)

similarity

double similarity(string|resource $file)

Calcuates the similarity to another image., (*13)

$file

Path to a file or a resource of that., (*14)

AUTHOR

travail, (*15)

LICENSE

This library is free software. You can redistribute it and/or modify it under the same terms as PHP itself., (*16)

The Versions

24/09 2017

dev-develop

dev-develop

travail/image-perceptualhash

  Sources   Download

PHP-3.0

The Requires

  • ext-gd *

 

The Development Requires

09/10 2015

dev-master

9999999-dev

travail/image-perceptualhash

  Sources   Download

PHP-3.0

The Requires

  • ext-gd *

 

The Development Requires

09/10 2015

v0.1.0

0.1.0.0

travail/image-perceptualhash

  Sources   Download

PHP-3.0

The Requires

  • ext-gd *

 

The Development Requires