Tracking meta source file for EXIF data.

This commit is contained in:
ThePendulum 2018-04-24 22:25:48 +02:00
parent f4535e443b
commit 5b20a538ff
1 changed files with 24 additions and 0 deletions

24
src/save/meta.js Normal file
View File

@ -0,0 +1,24 @@
'use strict';
const exiftool = require('node-exiftool');
const exiftoolBin = require('dist-exiftool');
function saveMeta(filepath, meta, globalExifTool) {
const ep = globalExifTool || new exiftool.ExiftoolProcess(exiftoolBin);
return Promise.resolve().then(() => {
if(!globalExifTool) {
return ep.open();
}
}).then(() => {
return ep.writeMetadata(filepath, meta, ['overwrite_original']);
}).then(() => {
console.log('\x1b[36m%s\x1b[0m', `Wrote metadata to '${filepath}'`);
}).then(() => {
if(!globalExifTool) {
return ep.close();
}
});
};
module.exports = saveMeta;