Phash Bindings for Node.js
Switch branches/tags
Nothing to show
Pull request Compare This branch is 19 commits behind aaronm67:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
examples
lib
test
.gitignore
.travis.yml
LICENSE
README.md
binding.gyp
index.js
package.json
phash.cpp

README.md

node-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)

Build Status

Installation

node-phash 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

Functions

// asynchronous hash
imageHash(filename, function(err, hash));

// synchronous hash
var hash = imageHashSync(filename);

hammingDistance(hash1, hash2);

Usage

var pHash = require("phash");

pHash.imageHash("file.jpg", function(err, hash) {
    if (err) {
        throw err;
    }

    // hash is the pHash of file.jpg
});

var hashA = pHash.imageHashSync("a.jpg");
var hashB = pHash.imageHashSync("b.png");
var hammingAB = pHash.hammingDistance(hashA,hashB);
console.log("Hamming Distance A -> B: " + hammingAB);