Browse Source

Merge pull request #104 from songlibo/master

Output the diff image along with the original images
pull/116/head
James Cryer 7 years ago committed by GitHub
parent
commit
f5f0d3cd53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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

@ -528,8 +528,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