Skip to content

Jimp.diff() to make real resize before image compare#1288

Closed
altruer wants to merge 1 commit intojimp-dev:mainfrom
altruer:main
Closed

Jimp.diff() to make real resize before image compare#1288
altruer wants to merge 1 commit intojimp-dev:mainfrom
altruer:main

Conversation

@altruer
Copy link
Copy Markdown

@altruer altruer commented Apr 15, 2024

Order of images passed to Jimp.diff() affected the result

    const diff1 = Jimp.diff(await Jimp.read('img1.jpg'), await Jimp.read('img2.jpg'));
    console.log('diff 1', diff1.percent);
    const diff2 = Jimp.diff(await Jimp.read('img2.jpg'), await Jimp.read('img1.jpg'));
    console.log('diff 2', diff2.percent);

Results were

diff 1 0.5332172192928611
diff 2 0.026531444444444444

This happened because compare happened for non resized images
I fixed resizing of images, so now we compare images of same sizes

After changes in this pull requests results are

diff 1 0.11355172316561868
diff 2 0.11355172316561868

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants