Skip to content

aaronm67/node-phash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-phash

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, a simple Hamming distance between the two hashes will be a good indicator of how similar two images are.

Current version supports only image hashing. (no video & audio hashing)

Installation

node-phash depends on CImg, pHash, ImageMagicK.

On Ubuntu:

sudo apt-get install cimg-dev libphash0-dev

On OSX:

brew install phash imagemagick

Then, install using npm:

$ npm install phash

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

About

Phash Bindings for Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published