Bindings for node.js to pHash
node-pash is pHash bindings for 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.
Current version supports only image hashing. (no video & audio hashing)
sudo apt-get install cimg-dev libphash0-dev libmagickcore-dev
brew install phash imagemagick
Then, install using npm:
$ npm install phash
// asynchronous hashimageHashfilename ;// synchronous hashvar hash = imageHashSyncfilename;hammingDistancehash1 hash2;
var pHash = require"phash";pHashimageHash"file.jpg"if errthrow err;// hash is the pHash of file.jpg;var hashA = pHashimageHashSync"a.jpg";var hashB = pHashimageHashSync"b.png";var hammingAB = pHashhammingDistancehashAhashB;console.log"Hamming Distance A -> B: " + hammingAB;