Perceptual GIF hashing for easily finding near-duplicate GIFs.
- Install a recent version of imagemagick >=
v7
(brew install imagemagick
on Mac OS).
npm install --save phash-gif
const pHashGIF = require('phash-gif')
const hash1 = await pHashGIF.compute('./media/bubbles.gif')
const hash2 = await pHashGIF.compute('./media/bubbles-gifski.gif')
const diff = await pHashGIF.compare(hash1, hash2)
Returns: Promise<Array<Number>>
Computes a perceptual hash of the given GIF.
For animated gifs, the result will be an array of 126 floating point values, corresponding to the three image hashes of the first, middle, and last frames of the input gif.
For static gifs, the result will be an array of 42 floating point values, the same as returned by phash-im.
Type: String
Required
Path to a GIF file.
Returns: Promise<Number>
Computes the L2 norm of the two hashes returnd by phash.compute
(sum of squared differences).
Type: Array<Number>
Required
Perceptual hash of first image.
Type: Array<Number>
Required
Perceptual hash of second image.
- phash-im - Perceptual image hashing provided by imagemagick.
- pHash - A popular open source perceptual hash library.
MIT © Travis Fischer
Support my OSS work by following me on twitter