Skip to content

enrique-z/image-hash

 
 

Repository files navigation

Image Hash and Comparison

Calculate image hash

Requirements

  1. NodeJS
  2. Python

Getting started

  1. pip install -r requirements.txt
  2. npm install
  3. npm run dev

API

POST /hash

Calculates the wavelet hashing for a given image url. Url should be passed in a JSON object in the body of a request.
Image hashing is based on ImageHash Python library.
E.g.:

curl -X POST -H "Content-Type: application/json" -d '{"url": "https://some-image-url"}' localhost:5000/hash

Response

{
    binaryHash: "<some-64-binary-hash-value>",
    pHash: "<some-64-perceptual-hash-value>",
    wHash: "<some-64-wavelength-hash-value>",
}

POST /diff

Calculates the distance between passed hashes.
Body message should be in following structure

{
    "origin": "<64-chars-string-hash>",
    "candidates": ["some-hash", "another-hash"]
}
The method returns the array of distances between origin hash and candidates. The length of the response equals to the amount of candidates.

E.g.

curl -X POST -H "Content-Type: application/json" -d '{"origin":"fffffff9fc11fffee7ffeff0fffd1ff80fe006f0002000010003000300038007", "candidates": ["fffffff9fc11fffee7ffeff0fffd1ff80fe006f0002000010003000300038009"]}' localhost:5000/diff

[3]

About

Calculate image hash

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 70.7%
  • Python 20.9%
  • Dockerfile 6.7%
  • Shell 1.7%