phash-gif
Perceptual GIF hashing for easily finding near-duplicate GIFs.
Install
- Install a recent version of imagemagick >=
v7
(brew install imagemagick
on Mac OS).
npm install --save phash-gif
Usage
const pHashGIF = const hash1 = await pHashGIFconst hash2 = await pHashGIF const diff = await pHashGIF
API
pHashGIF.compute(input)
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.
input
Type: String
Required
Path to a GIF file.
pHashGIF.compare(hash1, hash2)
Returns: Promise<Number>
Computes the L2 norm of the two hashes returnd by phash.compute
(sum of squared differences).
hash1
Type: Array<Number>
Required
Perceptual hash of first image.
hash2
Type: Array<Number>
Required
Perceptual hash of second image.
Related
- phash-im - Perceptual image hashing provided by imagemagick.
- pHash - A popular open source perceptual hash library.
License
MIT © Travis Fischer