fix(core): gracefully handle missing Exif.Composite.ImageSize

Fixes #226
pull/224/head^2
Romain 4 years ago
parent c3ca18d97e
commit 59b539e38e

@ -133,7 +133,7 @@ function makeArray (value) {
function dimensions (exif) {
// Use the Composite field to avoid having to check all possible tag groups (EXIF, QuickTime, ASF...)
if (!exif.Composite) {
if (!exif.Composite || !exif.Composite.ImageSize) {
return {
width: null,
height: null

@ -228,11 +228,19 @@ describe('Metadata', function () {
should(meta.height).eql(600)
})
it('defaults to null otherwise', function () {
it('defaults to null when there is no Composite data', function () {
const exiftool = fixtures.exiftool()
const meta = new Metadata(exiftool)
should(meta.width).eql(null)
should(meta.width).eql(null)
})
it('defaults to null when there is no ImageSize data', function () {
const exiftool = fixtures.exiftool()
exiftool.Composite = { Other: 'Data' }
const meta = new Metadata(exiftool)
should(meta.width).eql(null)
should(meta.width).eql(null)
})
})
})

Loading…
Cancel
Save