Socket
Socket
Sign inDemoInstall

phash-image

Package Overview
Dependencies
14
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    phash-image

phash for images


Version published
Weekly downloads
18
increased by80%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

phash-image

NPM version Build status Test coverage Dependency Status License Downloads

pHash for images in node.js.

Phash is a library that will create a "perceptual hash" of media files, so similar files will return similar hashes. Typically to compare hashes, a simple Hamming distance between the two hashes is a good indicator of how similar two media files are.

Installation

phash-image depends on CImg, pHash, ImageMagicK.

On Ubuntu:

sudo apt-get install cimg-dev libphash0-dev libmagickcore-dev

On OSX:

brew install phash imagemagick

Then, install using npm:

$ npm install phash-image

API

phash(filename, [returnBigInt], [callback]).then( hash => )

var phash = require('phash-image');
// with a callback
phash(filename, (err, hash) => );
// as a promise
phash(filename).then( hash => );

If you want to return a ulong64 as a string to store in a database, set true as the second parameter.

phash(filename, true).then( bigint => )

phash.mh(filename, [callback]).then( hash => )

Phash's MH 72-byte length hash. This is slower, but should be more accurate.

phash.mh(filename).then( hash => )

Comparing phashes

To compare phashes, use hamming-distance.

Keywords

FAQs

Last updated on 02 Mar 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc