Browse Source

Output the diff image along with the original images for easy comparison.

pull/104/head
Libo Song 8 years ago
parent
commit
705d030823
  1. BIN
      nodejs-tests/PeopleComparedToPeople2WithOriginal.png
  2. 6
      nodejs-tests/compareImages.test.js
  3. 12
      resemble.js

BIN
nodejs-tests/PeopleComparedToPeople2WithOriginal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

6
nodejs-tests/compareImages.test.js

@ -21,6 +21,12 @@ describe('compareImages', () => {
); );
expect(buffer.equals(comparison)).toBe(true); expect(buffer.equals(comparison)).toBe(true);
const buffer2 = data.getBuffer(true);
const comparison2 = fs.readFileSync(
'./nodejs-tests/PeopleComparedToPeople2WithOriginal.png'
);
expect(buffer2.equals(comparison2)).toBe(true);
}); });
test('throws when failed', async () => { test('throws when failed', async () => {

12
resemble.js

@ -513,8 +513,16 @@ URL: https://github.com/Huddle/Resemble.js
}; };
if (hiddenCanvas.toBuffer) { if (hiddenCanvas.toBuffer) {
data.getBuffer = function() { data.getBuffer = function(includeOriginal) {
context.putImageData(imgd, 0, 0); if (includeOriginal) {
var imageWidth = hiddenCanvas.width + 2;
hiddenCanvas.width = imageWidth * 3;
context.putImageData(img1, 0, 0);
context.putImageData(img2, imageWidth, 0);
context.putImageData(imgd, imageWidth * 2, 0);
} else {
context.putImageData(imgd, 0, 0);
}
return hiddenCanvas.toBuffer(); return hiddenCanvas.toBuffer();
} }
} }

Loading…
Cancel
Save