https://github.com/jasterv/imgphash
Provide an image class that is able to calculate similarity to other images using the phash value
https://github.com/jasterv/imgphash
Last synced: 3 months ago
JSON representation
Provide an image class that is able to calculate similarity to other images using the phash value
- Host: GitHub
- URL: https://github.com/jasterv/imgphash
- Owner: JasterV
- License: mit
- Created: 2022-03-21T09:38:15.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-09-02T05:57:27.000Z (almost 2 years ago)
- Last Synced: 2025-07-31T01:54:17.014Z (11 months ago)
- Language: JavaScript
- Size: 200 KB
- Stars: 4
- Watchers: 0
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Welcome to imgphash 👋
> Provide an image class that is able to calculate similarity to other images using the phash value
### 🏠 [Homepage](https://github.com/JasterV/imgphash#readme)
## Install
```sh
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
```javascript
const image = await HashImage.fromUrl(url1);
```
- Create a `HashImage` from a Node buffer
```javascript
const image = new HashImage(buffer);
```
- Get the hash of 2 images and compare them
```javascript
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
```javascript
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 **
## 🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check [issues page](https://github.com/JasterV/imgphash/issues).
## Show your support
Give a ⭐️ if this project helped you!
## 📝 License
Copyright © 2022 [Victor Martinez ](https://github.com/JasterV).
This project is [MIT](https://github.com/JasterV/imgphash/blob/main/LICENSE) licensed.
---
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_