From dc5cf14355472efba5719e846f4973174b968488 Mon Sep 17 00:00:00 2001 From: Romain Date: Tue, 15 Oct 2019 23:05:48 +0200 Subject: [PATCH] feat(metadata): add GPS lat/long --- src/model/metadata.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/model/metadata.js b/src/model/metadata.js index ae22a80..ed483cd 100644 --- a/src/model/metadata.js +++ b/src/model/metadata.js @@ -33,10 +33,11 @@ class Metadata { const size = dimensions(exiftool) this.width = size.width this.height = size.height + this.lat = tagValueFloat(exiftool, 'Composite', 'GPSLatitude') + this.long = tagValueFloat(exiftool, 'Composite', 'GPSLongitude') + // include the whole Exiftool output for more flexibility this.exif = opts ? (opts.embedExif ? exiftool.EXIF : undefined) : undefined // metadata could also include fields like - // - lat = 51.5 - // - long = 0.12 // - country = "England" // - city = "London" // - aperture = 1.8 @@ -121,6 +122,11 @@ function tagValue (exif, type, name) { return exif[type][name] } +function tagValueFloat (exif, type, name) { + const val = tagValue(exif, type, name) + return val ? parseFloat(val) : val +} + function picasaValue (picasa, name) { if (typeof picasa !== 'object') return null return picasa[name]