0.5.0 ā€¢ Published 1 month ago

imgphash v0.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Provide an image class that is able to calculate similarity to other images using the phash value

šŸ  Homepage

Install

npm i imgphash

Use

This module provides a class HashImage that you can use to hash an image and compare it

  • Create a HashImage from a url
const image = await HashImage.fromUrl(url1);
  • Create a HashImage from a Node buffer
const image = new HashImage(buffer);
  • Get the hash of 2 images and compare them
const image1 = await HashImage.fromUrl(url1);
const image2 = await HashImage.fromUrl(url2);
const hash1 = await image1.phash(); // PHash instance
const hash2 = await image2.phash();
const similarity = hash1.compare(hash2);

The hash function returns an instance of PHash

  • Or just compare 2 image objects, this is going to internally calculate their hash and use it
const image1 = await HashImage.fromUrl(url1);
const image2 = await HashImage.fromUrl(url2);
const similarity = await image1.compare(image2);

All the comparisons return a value between 0 and 1. 0 meaning that the images are completely different and 1 meaning they are exactly the same image

Author

šŸ‘¤ Victor Martinez jaster.victor@gmail.com

šŸ¤ Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ā­ļø if this project helped you!

šŸ“ License

Copyright Ā© 2022 Victor Martinez <jaster.victor@gmail.com>. This project is MIT licensed.


This README was generated with ā¤ļø by readme-md-generator

0.5.0

1 month ago

0.4.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago