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.
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
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's MH 72-byte length hash. This is slower, but should be more accurate.
phash.mh(filename).then( hash => )
To compare phashes, use hamming-distance.