2.2.2 • Published 9 months ago

dads-original-perceptual-hash v2.2.2

Weekly downloads
-
License
The Unlicense
Repository
-
Last release
9 months ago

dads-original-perceptual-hash

npm.io

Now with a spicy nodejs flavoring (both artificial and natural additives included).

Sharp-based implementation of perceptual hash (phash) algorithm. My main man Denis wrote this and I just refactored it and added a test and a shitty logo.

How to use

Takes in file buffer and returns a promise that resolves to a binary phash.

import {phash, distance} from 'sharp-phash'

import fs from 'fs/promises'

const main = async () => {
    const img1 = await fs.readFile('./test.png')
    const img2 = await fs.readFile('./test1.png')

    const hash1 = await phash(img1)
    const hash2 = await phash(img2)
    assert(dist(hash1, hash2) < 5)
}
main()

How it really works: the details

I'm not really sure. Math, maybe?

2.2.2

9 months ago