Closed rcfrias closed 5 years ago
Hi Vladimir! I tried to comparison two .jpg images but I have the error. Could you, please, provide a small example?
./node_modules/pixelmatch/bin/pixelmatch 1.jpg 2.jpg output.png 0.1
Hi @rcfrias! I wrote some ex.
const fs = require('fs');
const pixelmatch = require('pixelmatch');
const PNG = require('pngjs').PNG;
const JPEG = require('jpeg-js');
const jpegData1 = fs.readFileSync('img1.jpg');
const img1 = JPEG.decode(jpegData1);
const jpegData2 = fs.readFileSync('img2.jpg');
const img2 = JPEG.decode(jpegData2);
const diff = new PNG({ width: img1.width, height: img1.height });
pixelmatch(img1.data, img2.data, diff.data, img1.width, img1.height, { threshold: 0.1 });
diff.pack().pipe(fs.createWriteStream('diff.png'));
No, but it doesn't matter for the algorithm.