PHPackages                             bdelespierre/php-phash - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. bdelespierre/php-phash

ActiveLibrary[Image &amp; Media](/categories/media)

bdelespierre/php-phash
======================

pHash implementation in PHP

v1.0.1(5y ago)7532MITPHPPHP ~7.3

Since Aug 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/bdelespierre/php-phash)[ Packagist](https://packagist.org/packages/bdelespierre/php-phash)[ Docs](https://github.com/bdelespierre/php-phash)[ RSS](/packages/bdelespierre-php-phash/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

PHP pHash Implementation
========================

[](#php-phash-implementation)

[![Latest Version on Packagist](https://camo.githubusercontent.com/73b35f2f16d67105c813995231b35a0b24c7bb6ab149ac35af85eec72383b277/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6264656c65737069657272652f7068702d70686173682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bdelespierre/php-phash)[![Build Status](https://camo.githubusercontent.com/66095c5001f454dfff2e55dde435b40a4de8da93e7d415576710b2ae1d1e9473/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6264656c65737069657272652f7068702d70686173682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/bdelespierre/php-phash)[![Quality Score](https://camo.githubusercontent.com/de367d55abf74e01e89d25aeeb449954149bfebf05597816fa0808ecbad4abf6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6264656c65737069657272652f7068702d70686173682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bdelespierre/php-phash)[![Total Downloads](https://camo.githubusercontent.com/1fbeacd18c3b9760f4004b0b58f770be2864dac45f57e664aa63063853df2b03/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6264656c65737069657272652f7068702d70686173682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bdelespierre/php-phash)

Computes the pHash ([Perceptive Hash](http://www.hackerfactor.com/blog/index.php?/archives/432-Looks-Like-It.html)) of an image to compare images.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require bdelespierre/php-phash
```

Usage
-----

[](#usage)

```
vendor/bin/phash generate
vendor/bin/phash compare
```

```
require "vendor/autoload.php";

use Bdelespierre\PhpPhash\PHash;
use Intervention\Image\ImageManager;

$manager = new ImageManager(['driver' => 'imagick']);
$phash = new PHash($manager);

$hash = $phash->hash(new \SplFileInfo("image.jpg"));
$bash_hex = base_convert($bits, 2, 16);

echo $base_hex; // ffffef0001900000
```

Compare 2 hashes using [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance)

```
$hash1 = $phash->hash(new \SplFileInfo("image1.jpg"));
$hash2 = $phash->hash(new \SplFileInfo("image2.jpg"));

$dist = 0;
for ($i = 0; $i < $size ** 2; $i++) {
    if ($hash1[$i] != $hash2[$i]) {
        $dist++;
    }
}

echo "Hamming distance is: {$dist}";
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Benjamin Delespierre](https://github.com/bdelespierre)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2097d ago

PHP version history (2 changes)v1.0.0PHP ~7.2

v1.0.1PHP ~7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/49e2b252b26a5d1644723184b0f832ba927620af3b9b628bd7c60f08909ad736?d=identicon)[bdelespierre](/maintainers/bdelespierre)

---

Top Contributors

[![bdelespierre](https://avatars.githubusercontent.com/u/1086339?v=4)](https://github.com/bdelespierre "bdelespierre (10 commits)")

---

Tags

phashbdelespierreimage hashing algorithm

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bdelespierre-php-phash/health.svg)

```
[![Health](https://phpackages.com/badges/bdelespierre-php-phash/health.svg)](https://phpackages.com/packages/bdelespierre-php-phash)
```

###  Alternatives

[jenssegers/imagehash

Perceptual image hashing for PHP

2.1k2.2M5](/packages/jenssegers-imagehash)[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M102](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[ambroisemaupate/intervention-request

A customizable Intervention Image wrapper to use image simple re-sampling features over urls and a configurable cache.

4242.4k2](/packages/ambroisemaupate-intervention-request)[danihidayatx/image-optimizer

Optimize your Filament images before they reach your database. Forked from joshembling/image-optimizer for Filament v4 &amp; v5 support.

254.4k](/packages/danihidayatx-image-optimizer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
