Skip to content

aaronm67/node-phash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Installation

$ npm install phash

Usage

var pHash = require("phash");

pHash.imageHash("file.jpg", function(err, hash) {
    if (err) {
        console.error(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);

API

pHash#imageHash

Computes a pHash asynchronously.

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

pHash#imageHashSync

Computes a pHash.

var hash = imageHashSync(filename);

pHash#hammingDistance

Computes the Hamming distance between the two pHashes.

hammingDistance(hashA, hashB);

License

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.

About

Phash Bindings for Node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published