jimp-dev / jimp

An image processing library written entirely in JavaScript for Node, with zero external or native dependencies.
http://jimp-dev.github.io/jimp/
MIT License
13.87k stars 760 forks source link

Whether phash is calculated correctly #1221

Open chaserstrong opened 1 year ago

chaserstrong commented 1 year ago

Expected Behavior

I have two pictures which look vary similar:

image image

The original image link is below: https://user-images.githubusercontent.com/18061322/230870421-1a6b4b6d-e2c3-42d6-be9a-4393a56166f2.png https://user-images.githubusercontent.com/18061322/230870522-a20d7b6e-f2e5-4713-a3c9-b4e338ecf33f.png

And by the code, phash is 0.21875 which is too big in my opinion

Current Behavior

this is my code:

var imgUrls = require("./constant");
var Jimp = require("jimp");
(async () => {
  let img1 = await Jimp.read(imgUrls.closeIcon1);
  let img2 = await Jimp.read(imgUrls.closeIcon2);
  let hash1 = img1.pHash();
  let hash2 = img2.pHash();
  console.log(img2.distanceFromHash(hash1)); // 0.21875
  console.log(Jimp.diff(img1, img2).percent); // 0
})();

Failure Information (for bugs)

Steps to Reproduce

Screenshots

Context

Failure Logs

chaserstrong commented 1 year ago

@hipstersmoothie

hipstersmoothie commented 5 months ago

if you have a bug fix feel free to submit a pr!