2

I am trying to do a comparison of 2 images and highlight the difference in a third Image using node-resemble-js.

Tried the following code:

var imgData1 = 'C:\\Users\\Image1.png';
var imgData2 = 'C:\\Users\\Image2.png';

var diffImage = 'C:\\Users\\';

    resemble(imgData1).compareTo(imgData2).ignoreNothing().onComplete(function (data) {

        data.getDiffImage().pack().pipe(fs.createWriteStream( diffImage + 'diff.png'));
        console.log(data);
    })

But, getting an empty ‘diff’ image. The log shows that the 2 images are different:

{ isSameDimensions: true,
  dimensionDifference: { width: 0, height: 0 },
  misMatchPercentage: '0.73',
  analysisTime: 143,
  getDiffImage: [Function] }

Don’t know what am I missing here, Any help would be much appreciated.

Sim_8
  • 56
  • 4

1 Answers1

0

I have a slightly different code and it works for me:

var fs = require('fs'); 
var resemble = require('node-resemble-js');

var img1 = fs.readFileSync('./img1.png');
var img2 = fs.readFileSync('./img2.png');

resemble(img1).compareTo(img2).ignoreNothing().onComplete(function (data) {
    data.getDiffImage().pack().pipe(fs.createWriteStream( './diff.png'));
    console.log(data);
});

This does what it should do. Hope that helps.

user2718671
  • 2,866
  • 9
  • 49
  • 86