Skip to content

Commit

Permalink
Update readme with decimal mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jenssegers committed Feb 20, 2016
1 parent a044264 commit 20d1ee5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ Usage
Calculating a perceptual hash for an image using the default implementation:

```php
$hasher = new Jenssegers\ImageHash\ImageHash;
use Jenssegers\ImageHash\ImageHash;

$hasher = new ImageHash;
$hash = $hasher->hash('path/to/image.jpg');
```

Expand All @@ -48,18 +50,26 @@ Equal images will not always have a distance of 0, so you will need to decide at
Calculating a perceptual hash for an image using a different implementation:

```php
$implementation = new Jenssegers\ImageHash\Implementations\DifferenceHash;
$hasher = new Jenssegers\ImageHash\ImageHash($implementation);
use Jenssegers\ImageHash\Implementations\DifferenceHash;
use Jenssegers\ImageHash\ImageHash;

$implementation = new DifferenceHash;
$hasher = new ImageHash($implementation);
$hash = $hasher->hash('path/to/image.jpg');
```

Compare 2 images and get their hamming distance:

```php
$hasher = new Jenssegers\ImageHash\ImageHash;
$distance = $hasher->compare('path/to/image1.jpg', 'path/to/image2.jpg');
```

If you prefer to have decimal image hashes, you can change the mode during the construction of the `ImageHash` instance:

```php
$hasher = new ImageHash($implementation, ImageHash::DECIMAL);
```

Demo
----

Expand Down

0 comments on commit 20d1ee5

Please sign in to comment.