Skip to content

Perceptual GIF hashing for easily finding near-duplicate GIFs.

Notifications You must be signed in to change notification settings

transitive-bullshit/phash-gif

Repository files navigation

phash-gif

Perceptual GIF hashing for easily finding near-duplicate GIFs.

NPM Build Status JavaScript Style Guide

Install

  • Install a recent version of imagemagick >= v7 (brew install imagemagick on Mac OS).
npm install --save phash-gif

Usage

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)

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

Support my OSS work by following me on twitter twitter

About

Perceptual GIF hashing for easily finding near-duplicate GIFs.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published