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 1mo ago

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 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

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

1162d 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

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

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