No longer using imgur API for individual images. Only saving EXIF data to JPEGs. Always using global exiftool instance.

This commit is contained in:
2018-07-05 02:00:45 +02:00
parent 5dce74588b
commit f5382ddc37
4 changed files with 37 additions and 47 deletions

View File

@@ -1,24 +1,9 @@
'use strict';
const exiftool = require('node-exiftool');
const exiftoolBin = require('dist-exiftool');
async function saveMeta(filepath, meta, ep) {
await ep.writeMetadata(filepath, meta, ['overwrite_original']);
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();
}
});
};
console.log('\x1b[36m%s\x1b[0m', `Wrote metadata to '${filepath}'`);
}
module.exports = saveMeta;