Merge pull request #133 from amcolash/preserve_exif

Preserve exif information during import
pull/134/head
Romain 6 years ago committed by GitHub
commit 8ba1aeae8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -115,6 +115,7 @@ Website options:
--title Website title [default: "Photo album"]
--footer Text or HTML footer [default: null]
--google-analytics Code for Google Analytics tracking [string]
--embed-exif Embed exif metadata for each image into the gallery page (enable to use exif plugin) [boolean] [default: false]
Deprecated:
--original-photos Copy and allow download of full-size photos [boolean] [default: false]

@ -172,6 +172,12 @@ const OPTIONS = {
description: 'Code for Google Analytics tracking',
type: 'string'
},
'embed-exif': {
group: 'Website options:',
description: 'Embed the exif metadata for each image into the gallery page',
type: 'boolean',
'default': false
},
// ------------------------------------
// Misc options
@ -299,7 +305,8 @@ exports.get = (args) => {
concurrency: opts['concurrency'],
gmArgs: opts['gm-args'],
watermark: opts['watermark'],
watermarkPosition: opts['watermark-position']
watermarkPosition: opts['watermark-position'],
embedExif: opts['embed-exif']
}
}

@ -21,7 +21,7 @@ const FILENAME_DATE_REGEX = /\d{4}[_\-.\s]?(\d{2}[_\-.\s]?){5}\..{3,4}/
const FILENAME_DATE_FORMAT = 'YYYYMMDD HHmmss'
class Metadata {
constructor (exiftool, picasa) {
constructor (exiftool, picasa, opts) {
// standardise metadata
this.date = getDate(exiftool)
this.caption = caption(exiftool)
@ -30,6 +30,7 @@ class Metadata {
this.animated = animated(exiftool)
this.rating = rating(exiftool)
this.favourite = favourite(picasa)
this.exif = opts ? (opts.embedExif ? exiftool.EXIF : undefined) : undefined
// metadata could also include fields like
// - lat = 51.5
// - long = 0.12

@ -39,7 +39,7 @@ exports.run = function (opts, callback) {
// emitted for every file once indexing is finished
emitter.on('file', file => {
const picasa = picasaReader.file(file.metadata.SourceFile)
const meta = new Metadata(file.metadata, picasa || {})
const meta = new Metadata(file.metadata, picasa || {}, opts)
const model = new File(file.metadata, meta, opts)
// only include valid photos and videos (i.e. exiftool recognised the format)
if (model.type !== 'unknown') {

@ -23,7 +23,26 @@
<li data-src="{{relative urls.large}}"
data-sub-html="{{meta.caption}}"
data-download-url="{{relative urls.download}}">
data-download-url="{{relative urls.download}}"
data-filename="{{filename}}"
{{#if meta.exif}}
data-datetimeoriginal="{{meta.exif.DateTimeOriginal}}"
data-fnumber="{{meta.exif.FNumber}}"
data-exposuretime="{{meta.exif.ExposureTime}}"
data-isospeedratings="{{meta.exif.ISO}}"
data-focallength="{{meta.exif.FocalLength}}"
data-lens="{{meta.exif.Lens}}"
data-model="{{meta.exif.Model}}"
data-make="{{meta.exif.Make}}"
data-gpslatitude="{{meta.exif.GPSLatitude}}"
data-gpslongitude="{{meta.exif.GPSLongitude}}"
data-gpslatituderef="{{meta.exif.GPSLatitudeRef}}"
data-gpslongituderef="{{meta.exif.GPSLongitudeRef}}"
data-gpsaltitude="{{meta.exif.GPSAltitude}}"
{{/if}}
>
<a href="{{relative urls.download}}">
<img src="{{relative urls.thumbnail}}"
width="{{@root.gallery.thumbSize}}"

Loading…
Cancel
Save