Skip to content

Repository files navigation

pHash NPM versionBuild Status

pHash bindings for Node.js.

A pHash is a "perceptual hash" of a multimedia file derived from various features from its content. This can be useful to compare similar files, create database indices and so on.

Note: Currently supports only images - no video or audio.

Installation

$ npm install phash

Usage

varpHash=require("phash");pHash.imageHash("file.jpg",function(err,hash){if(err){console.error(err);}console.log("pHash: "+hash);});varhashA=pHash.imageHashSync("a.jpg");varhashB=pHash.imageHashSync("b.png");varhammingAB=pHash.hammingDistance(hashA,hashB);console.log("Hamming Distance A -> B: "+hammingAB);

API

pHash#imageHash

Computes a pHash asynchronously.

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

pHash#imageHashSync

Computes a pHash.

varhash=imageHashSync(filename);

pHash#hammingDistance

Computes the Hamming distance between the two pHashes.

hammingDistance(hashA, hashB);

License

Licensed under the incredibly permissiveMIT License. Copyright © 2013 Aaron Marasco.
Dependencies may be licensed diffrently.

NOTE: The Node bindings for pHash provided are are MIT licensed and may be used and modified freely. You must also comply with the terms of whichever pHash License you are using.

About

Phash Bindings for Node.js

Resources

Stars

164 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages