Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

JasterV/imgphash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ This repo has been migrated ⚠️

Mainly for philosofic reasons I've decided to migrate all my projects to a free software alternative forge (Codeberg).

You can find the most recent version of this repository here.

I encourage any free software activist to follow the same steps, as it doesn't make sense to make use of a propietary software to host our projects if we advocate for free software.

Welcome to imgphash 👋

Version Documentation Maintenance License: MIT

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

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

About

⚠️ This repo has been migrated ⚠️ Provide an image class that is able to calculate similarity to other images using the phash value

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors