Add raw EXIF data to metadata response

Copy metadata input buffer to match pipeline

Prevents possible metadata segfault under load
This commit is contained in:
Lovell Fuller
2015-06-28 23:35:40 +01:00
parent 86490bedfb
commit 6ac47c1ef8
7 changed files with 58 additions and 17 deletions

View File

@@ -2,6 +2,7 @@
var fs = require('fs');
var assert = require('assert');
var exifReader = require('exif-reader');
var sharp = require('../../index');
var fixtures = require('../fixtures');
@@ -21,6 +22,7 @@ describe('Image metadata', function() {
assert.strictEqual(false, metadata.hasProfile);
assert.strictEqual(false, metadata.hasAlpha);
assert.strictEqual('undefined', typeof metadata.orientation);
assert.strictEqual('undefined', typeof metadata.exif);
done();
});
});
@@ -36,6 +38,12 @@ describe('Image metadata', function() {
assert.strictEqual(true, metadata.hasProfile);
assert.strictEqual(false, metadata.hasAlpha);
assert.strictEqual(8, metadata.orientation);
assert.strictEqual('object', typeof metadata.exif);
assert.strictEqual(true, metadata.exif instanceof Buffer);
var exif = exifReader(metadata.exif);
assert.strictEqual('object', typeof exif);
assert.strictEqual('object', typeof exif.image);
assert.strictEqual('number', typeof exif.image.XResolution);
done();
});
});

2
test/unit/overlay.js Normal file → Executable file
View File

@@ -147,7 +147,6 @@ describe('Overlays', function() {
sharp(fixtures.inputJpg)
.overlayWith(fixtures.inputPngWithGreyAlpha)
.toBuffer(function(error) {
console.dir(error);
assert.strictEqual(true, error instanceof Error);
done();
});
@@ -157,7 +156,6 @@ describe('Overlays', function() {
sharp(fixtures.inputPngOverlayLayer1)
.overlayWith(fixtures.inputJpg)
.toBuffer(function(error) {
console.dir(error);
assert.strictEqual(true, error instanceof Error);
done();
});