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

This commit is contained in:
2024-09-11 05:16:56 +02:00
parent b05ae06b00
commit dbc4c45601
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;