1.0.0 • Published 2 years ago

@myur4/dhash v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Imgur

Fast, reliable and deadly simple node module which implements the "Dhash" which has the ability to load/compare/hash images with pixel-range precision under few milliseconds and discards the use of machine learning (OpenCV and similar). Note that this module is used to measure difference, which means its able to not just compare if two images are the same, but point the similarity/difference level of them

Actually, that's the only decent and full-maintained package which implements Dhash for NodeJS. Also, a big thanks for the Sharp lib's maintainers for their hard work and perfectionism into binding libvps for JavaScript.

The distance between two images is measured according to its distance, which 0 means EQUAL/NOT DIFFERENCE FOUND and anything > 0 means a difference level found. Inside our tests, comparisons which returns a distance greater than 20 represent a completely different image, and 1~5 represents a huge similarity.

🖼️ How to use it? Let's see:

const imageHash = require("image-hash");

async function someFunction() {
    /* Compares images from its paths */
    const difference = await imageHash.compareImages("PATH/TO/IMAGE0", "PATH/TO/IMAGE1");
    // Outputs: { distance: number, hashes: { image0: string, image1: string }}
    
    /* Comparing images from its generated hashes */
    const differenceHash = imageHash.compareHashes("HASH", "HASH2");
    // Outputs: distance (number)
    
    /* Generate hash from a single image */
    const myHash = await imageHash.calculateHash("PATH/TO/IMAGE");
    // Outputs: hash (string, length: 18)
}

📝 TODO LIST

  • Implement Dhash
  • Cleanup code & comments
  • Publish first release to GitHub
  • Convert code into TypeScript (or add typings)
  • Make it able to be posted in NPM
  • Publish first release to NPM