phash-image

3.5.0 • Public • Published

phash-image

NPM version Build status Test coverage Dependency Status License Downloads

pHash for images in node.js.

Phash is a library that will create a "perceptual hash" of media files, so similar files will return similar hashes. Typically to compare hashes, a simple Hamming distance between the two hashes is a good indicator of how similar two media files are.

Installation

phash-image depends on CImg, pHash, ImageMagicK.

On Ubuntu:

sudo apt-get install cimg-dev libphash0-dev libmagickcore-dev

On OSX:

brew install phash imagemagick

Then, install using npm:

$ npm install phash-image

API

phash(filename, [returnBigInt], [callback]).then( hash => )

var phash = require('phash-image');
// with a callback
phash(filename, (err, hash) => );
// as a promise
phash(filename).then( hash => );

If you want to return a ulong64 as a string to store in a database, set true as the second parameter.

phash(filename, true).then( bigint => )

phash.mh(filename, [callback]).then( hash => )

Phash's MH 72-byte length hash. This is slower, but should be more accurate.

phash.mh(filename).then( hash => )

Comparing phashes

To compare phashes, use hamming-distance.

Package Sidebar

Install

npm i phash-image

Weekly Downloads

5

Version

3.5.0

License

MIT

Last publish

Collaborators

  • plasmapower
  • jongleberry
  • lovell