2017-07-24 11:40:03 +00:00
|
|
|
const moment = require('moment')
|
|
|
|
const File = require('../src/model/file')
|
|
|
|
const Metadata = require('../src/model/metadata')
|
2016-10-10 11:49:08 +00:00
|
|
|
|
2017-07-24 11:40:03 +00:00
|
|
|
exports.exiftool = function (opts) {
|
2017-03-06 11:16:36 +00:00
|
|
|
opts = opts || {}
|
2016-10-10 11:49:08 +00:00
|
|
|
return {
|
2017-07-24 11:40:03 +00:00
|
|
|
SourceFile: opts.path || 'path/image.jpg',
|
|
|
|
File: {
|
|
|
|
FileModifyDate: opts.date || '2016:08:24 14:51:36',
|
|
|
|
MIMEType: opts.mimeType || 'image/jpg'
|
|
|
|
},
|
|
|
|
EXIF: {},
|
2017-12-23 09:32:10 +00:00
|
|
|
IPTC: {
|
|
|
|
Keywords: opts.keywords
|
|
|
|
},
|
2017-07-24 11:40:03 +00:00
|
|
|
XMP: {},
|
|
|
|
H264: {},
|
|
|
|
QuickTime: {}
|
2017-03-06 11:16:36 +00:00
|
|
|
}
|
|
|
|
}
|
2016-10-10 11:49:08 +00:00
|
|
|
|
2017-07-24 11:40:03 +00:00
|
|
|
exports.metadata = function (opts) {
|
|
|
|
return new Metadata(exports.exiftool(opts))
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.file = function (opts) {
|
|
|
|
const exiftool = exports.exiftool(opts)
|
|
|
|
const meta = new Metadata(exiftool)
|
|
|
|
return new File(exiftool, meta)
|
|
|
|
}
|
|
|
|
|
2017-03-06 11:16:36 +00:00
|
|
|
exports.date = function (str) {
|
2017-07-24 11:40:03 +00:00
|
|
|
return new Date(moment(str, 'YYYYMMDD HHmmss').valueOf())
|
|
|
|
// return new Date(Date.parse(str))
|
2017-03-06 11:16:36 +00:00
|
|
|
}
|
2016-10-10 11:49:08 +00:00
|
|
|
|
2017-03-06 11:16:36 +00:00
|
|
|
exports.photo = function (opts) {
|
|
|
|
opts = opts || {}
|
2017-07-24 11:40:03 +00:00
|
|
|
opts.mimeType = 'image/jpg'
|
|
|
|
return exports.file(opts)
|
2017-03-06 11:16:36 +00:00
|
|
|
}
|
2016-10-10 11:49:08 +00:00
|
|
|
|
2017-03-06 11:16:36 +00:00
|
|
|
exports.video = function (opts) {
|
|
|
|
opts = opts || {}
|
2017-07-24 11:40:03 +00:00
|
|
|
opts.mimeType = 'video/mp4'
|
|
|
|
return exports.file(opts)
|
2017-03-06 11:16:36 +00:00
|
|
|
}
|