PHPackages                             nbsbbs/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. nbsbbs/phash

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

nbsbbs/phash
============

Counts perceptual hash of images

1.0.2(3y ago)016MITPHPPHP &gt;=7.4

Since Mar 9Pushed 3y agoCompare

[ Source](https://github.com/Nbsbbs/phash)[ Packagist](https://packagist.org/packages/nbsbbs/phash)[ RSS](/packages/nbsbbs-phash/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)DependenciesVersions (4)Used By (0)

Phash
=====

[](#phash)

Perceptual hash implementation for PHP

This is my PHP Implementation of the AverageHash algorithm to create Perceptual Hashes

A perceptual hash is different from a typical hash as it allows you to compute a signature based on the visual features of an image rather than the actual data they contain as with a cryptographic hash. This allows you to use the Perceptual Hash for simple image matching which could prove useful in finding duplicate pictures or picture tagging.

To get a better understanding of this project see:

---

### Sample Usage

[](#sample-usage)

You can use pHash methods as a class in your project and extend as you wish.

A basic implementation is as follows:

```
#sample implementation
$phasher = new Phash;
$phash2 = $phasher->getHash('phash2.jpg', false);
//this will echo hash in hex, then binary
echo $phasher->hashAsString($phash2, false).PHP_EOL;
echo $phasher->hashAsString($phash2).PHP_EOL;

$phash3 = $phasher->getHash('phash3.jpg', false);
//this will echo hash in hex, then binary
echo $phasher->hashAsString($phash3, false).PHP_EOL;
echo $phasher->hashAsString($phash3).PHP_EOL;

//using BIT COUNT METHOD FOR SIMILARITY
echo $phasher->getSimilarity($phash2, $phash3, 'BITS');
echo PHP_EOL;

//using HAMMING METHOD (DEFAULT) FOR SIMILARITY
echo $phasher->getSimilarity($phash2, $phash3);
echo PHP_EOL;

```

Notes
-----

[](#notes)

- The bitcount algorithm for matching similarity may be siginificantly faster than hamming distance.
- Calculating hamming distance between two hex based hashes may be faster but less accurate than the binary version

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

3

Last Release

1212d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f3250c3b05ca17ae163e3c6c2a73d310aa22de2c74e9c8a4fd350a12e22ebbb8?d=identicon)[nbsbbs](/maintainers/nbsbbs)

---

Top Contributors

[![xwiz](https://avatars.githubusercontent.com/u/3619843?v=4)](https://github.com/xwiz "xwiz (7 commits)")[![mixailo](https://avatars.githubusercontent.com/u/135554?v=4)](https://github.com/mixailo "mixailo (4 commits)")[![opatachibueze](https://avatars.githubusercontent.com/u/805029?v=4)](https://github.com/opatachibueze "opatachibueze (2 commits)")[![4dr1en](https://avatars.githubusercontent.com/u/65124433?v=4)](https://github.com/4dr1en "4dr1en (1 commits)")[![divinity76](https://avatars.githubusercontent.com/u/1874996?v=4)](https://github.com/divinity76 "divinity76 (1 commits)")

### Embed Badge

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

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

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

135911.1k3](/packages/goat1000-svggraph)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

16653.6k2](/packages/gravatarphp-gravatar)[rsoury/wp-imgix

Rewrites WordPress image URLs to use ImgIX

167.2k](/packages/rsoury-wp-imgix)

PHPackages © 2026

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