rsmbl / Resemble.js

Image analysis and comparison

Home Page:http://rsmbl.github.io/Resemble.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to run sample code provide on Github main page.

Sumit-Soman opened this issue · comments

const compareImages = require("resemblejs/compareImages");
const fs = require("mz/fs");

async function getDiff() {
const options = {
output: {
errorColor: {
red: 255,
green: 0,
blue: 255
},
errorType: "movement",
transparency: 0.3,
largeImageThreshold: 1200,
useCrossOrigin: false,
outputDiff: true
},
scaleToSameSize: true,
ignore: "antialiasing"
};

// The parameters can be Node Buffers
// data is the same as usual with an additional getBuffer() function
const data = await compareImages(
    await fs.readFile("./demoassets/People.jpg"),
    await fs.readFile("./demoassets/People2.jpg"),
    options
);

await fs.writeFile("./output.png", data.getBuffer());

}

getDiff();

Used the above code, using my local images. code existed with no error.
On debugging control exist from compareImages method.
i am using png images do we need to use jpg only

It should work with a variety of image types.. I'm unable to investigate right now. Can you try using an earlier version of Resemble.js to see if that works?

Thanks for the prompt replay.
Downgraded to v2.10.3. Image Comparison is working fine. Same code

Unfortunately I am unable to reproduce the issue, the code above works for me with both PNG and JPG. I'll leave the ticket open for now

Hi James,

Issue was not with images type.

Latest version was not working producing the diff image. I was able to produce diff with lower version.
Downgraded to v2.10.3.

I could not reproduce the issue with ^3.0.0 on Node v10.13.0. It produced an image diff for me. What version of Node are you using?

Had another attempt with v8, but I am still unable to reproduce any issue, it works for me. I wonder if there is something about your images. Please let us know if you discover what the problem is. I'll leave the ticket open for now.