mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Expose IPTC and XMP metadata when available (#1079)
This commit is contained in:
committed by
Lovell Fuller
parent
8afcb16d8e
commit
c4df115948
BIN
test/fixtures/Landscape_9.jpg
vendored
Normal file
BIN
test/fixtures/Landscape_9.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
1
test/fixtures/index.js
vendored
1
test/fixtures/index.js
vendored
@@ -57,6 +57,7 @@ module.exports = {
|
||||
|
||||
inputJpg: getPath('2569067123_aca715a2ee_o.jpg'), // http://www.flickr.com/photos/grizdave/2569067123/
|
||||
inputJpgWithExif: getPath('Landscape_8.jpg'), // https://github.com/recurser/exif-orientation-examples/blob/master/Landscape_8.jpg
|
||||
inputJpgWithIptcAndXmp: getPath('Landscape_9.jpg'), // https://unsplash.com/photos/RWAIyGmgHTQ
|
||||
inputJpgWithExifMirroring: getPath('Landscape_5.jpg'), // https://github.com/recurser/exif-orientation-examples/blob/master/Landscape_5.jpg
|
||||
inputJpgWithGammaHoliness: getPath('gamma_dalai_lama_gray.jpg'), // http://www.4p8.com/eric.brasseur/gamma.html
|
||||
inputJpgWithCmykProfile: getPath('Channel_digital_image_CMYK_color.jpg'), // http://en.wikipedia.org/wiki/File:Channel_digital_image_CMYK_color.jpg
|
||||
|
||||
@@ -58,6 +58,23 @@ describe('Image metadata', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('JPEG with IPTC/XMP', function (done) {
|
||||
sharp(fixtures.inputJpgWithIptcAndXmp).metadata(function (err, metadata) {
|
||||
if (err) throw err;
|
||||
// IPTC
|
||||
assert.strictEqual('object', typeof metadata.iptc);
|
||||
assert.strictEqual(true, metadata.iptc instanceof Buffer);
|
||||
assert.strictEqual(18250, metadata.iptc.byteLength);
|
||||
assert.strictEqual(metadata.iptc.indexOf(Buffer.from('Photoshop')), 0);
|
||||
// XMP
|
||||
assert.strictEqual('object', typeof metadata.xmp);
|
||||
assert.strictEqual(true, metadata.xmp instanceof Buffer);
|
||||
assert.strictEqual(12495, metadata.xmp.byteLength);
|
||||
assert.strictEqual(metadata.xmp.indexOf(Buffer.from('http://ns.adobe.com/xap/1.0')), 0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('TIFF', function (done) {
|
||||
sharp(fixtures.inputTiff).metadata(function (err, metadata) {
|
||||
if (err) throw err;
|
||||
|
||||
Reference in New Issue
Block a user