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.



pHash NPM version Build Status

Node.js pHash 绑定。

pHash是从其内容的各种功能衍生的多媒体文件的感知散列。这可以用于比较类似的文件,创建数据库索引等。

注意:目前仅支持图像 - 无视频或音频。

安装

$ npm install phash

用法

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

异步计算pHash。

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

pHash#imageHashSync

计算一个pHash。

var hash = imageHashSync(filename);

pHash#hammingDistance

计算两个pH值之间的汉明距离

hammingDistance(hashA, hashB);

许可证

根据令人难以置信的允许许可许可麻省理工学院许可证。版权所有©2013 Aaron Marasco。
依赖关系可能会有不同的许可。

注意:提供的pHash的Node绑定是MIT许可的,可以自由使用和修改。您还必须遵守您正在使用的 pHash许可中的任何条款。




相关问题推荐