image-phash

1.0.1 • Public • Published

Image Hash

Lib for get unique hash from image for comparison. Using simple algorithm average color of bytes.

Install

npm install image-phash

Usage example

const imageHash = require('image-phash');
 
let hash1 = await imageHash.getHashFile('1.jpg');
let hash2 = await imageHash.getHashFile('2.jpg');
 
console.log(ImageHash.hammingDistance(hash1, hash2));

getHashFile(filePath, [options])

Get hash from file path. (Return promise)

options:

{
    resizeBeforeHash: [64, 64] // resize image befaore hashing [64, 64] by default
}

hammingDistance(hash1, hash2)

Calc hamming distance from hash1 and hash2. (It will help to know how much the first picture differs from the second by hash)

hashByAverageValueBytes(buffer)

Get hash from buffer of the image pixels (Throw error if passed not a buffer)

/image-phash/

    Package Sidebar

    Install

    npm i image-phash

    Weekly Downloads

    1

    Version

    1.0.1

    License

    none

    Last publish

    Collaborators

    • vfrbgt