Skip to content
Phash Bindings for Node.js
C++ JavaScript Python

pHash NPM version Build 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.


$ npm install phash


var pHash = require("phash");

pHash.imageHash("file.jpg", function(err, hash) {
    if (err) {
    console.log("pHash: " + hash);

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



Computes a pHash asynchronously.

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


Computes a pHash.

var hash = imageHashSync(filename);


Computes the Hamming distance between the two pHashes.

hammingDistance(hashA, hashB);


Licensed under the incredibly permissive MIT 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.

Something went wrong with that request. Please try again.