wayhome-phash
v0.0.7
Published
Bindings for node.js to pHash
Downloads
7
Maintainers
Readme
version built for wayhome. built on Ubuntu 16.10 to fix bug with npm install
.
https://github.com/aaronm67/node-phash/issues/23
pHash
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.