From f854dbb991c496ea1604c0ee57a9a5bed6349f29 Mon Sep 17 00:00:00 2001 From: travail Date: Tue, 3 Feb 2015 16:27:43 +0900 Subject: [PATCH] Add README.md --- README.md | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ef438e2 --- /dev/null +++ b/README.md @@ -0,0 +1,115 @@ +Image\PerceptualHash +======== + +## NAME + +Image\PerceptualHash - Generate comparable hash from images + +## SYNOPSIS + +```php +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. + +## INSTALLATION + +To install this package into your project via composer, add the following snippet to your `composer.json`. Then run `composer install`. + +``` +"require": { + "travail/image-perceptualhash": "dev-master" +} +``` + +or + +``` +"repositories": { + { + "type": "vcs", + "url": "git@github.com:travail/php-Image-PerceptualHash.git" + } +} +``` + +## DEPENDENCIES + +* ext-gd + +## METHODS + +### `public __construct($file, Algorithm $algorithm)` + +Creates a new instance of Image\PerceptualHash and calculates hashes. + +#### $file + +Path to a file or a resource of that. + +#### Algorithm $algorithm + +Hashing algorithm, currently the following algorithm are available: + +* AverageHash +* DifferenceHash +* PerceptionHash + +### `public bin()` + +Returns calculated binary hash. + +### `public hex()` + +Returns calculated hexadecimal hash. + +### `public compare(mixed $file)` + +Compares with another image and returns the Hamming distance to that. + +#### $file + +Path to a file or a resource of that. + +### `public similarity(mixed $file)` + +Calcuates the simiralrity to another image. + +#### $file + +Path to a file or a resource of that. + +## AUTHOR + +travail + +### LICENSE + +This library is free software. You can redistribute it and/or modify it under the same terms as PHP itself.