Code Monkey home page Code Monkey logo

phash-image's Introduction

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.

phash-image's People

Contributors

ada-lovecraft avatar avvs avatar bkw avatar dreampulse avatar jonathanong avatar lovell avatar xissy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.