Skip to content
Projets

pwlmc/imghash has 200 GitHub stars and 18 forks. Star changes are not measured yet. Last checked 2026-11-13 22:39 UTC. Last push 2026-11-11.

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
Historique en cours
in 7 days
Historique en cours
in 15 days
Historique en cours
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

À propos

Perceptual image hashing for Node.js

Outils de développement

README.md

Original

imghash Version License

Perceptual image hashing for Node.js

Installation

npm install imghash

Basic usage

import imghash from "imghash";

const hash1 = await imghash.hash("./path/to/file");
console.log(hash1); // "f884c4d8d1193c07"

// Use a 4-bit hash grid and return the result as binary
const hash2 = await imghash.hash("./path/to/file", 4, "binary");
console.log(hash2); // "1000100010000010"

Finding similar images

To measure similarity between images you can use Hamming distance or Levenshtein Distance.

The following example uses the latter one:

import imghash from "imghash";
import leven from "leven";

const hash1 = await imghash.hash("./img1");
const hash2 = await imghash.hash("./img2");

const distance = leven(hash1, hash2);
console.log(`Distance between images is: ${distance}`);
if (distance <= 12) {
  console.log("Images are similar");
} else {
  console.log("Images are NOT similar");
}

The threshold of 12 is a starting point, not a universal rule. Tune it for your image set and the hash size you use.

API

hash(filepath, bits?, format?)

Calculates a perceptual hash for an image.

const hash = await imghash.hash("./image.png", 8, "hex");
Parameter Type Default Description
filepath string | Buffer — Image path or image data.
bits number 8 Hash grid size. Must be divisible by 4.
format "hex" | "binary" "hex" Returned hash encoding.

Returns: Promise<string>.

See the full API Reference.

Read more

Explorer des projets similaires