phash-gif

0.0.3 • Public • Published

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

Package Sidebar

Install

npm i phash-gif

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

6.58 kB

Total Files

8

Last publish

Collaborators

  • fisch0920