Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

altruer
Copy link

@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.

None yet

1 participant