From e3899362d79ddacea2e27ae5348d198334a70364 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Wed, 11 Sep 2024 05:16:54 +0200 Subject: [PATCH] Tracking meta source file for EXIF data. --- src/save/meta.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/save/meta.js diff --git a/src/save/meta.js b/src/save/meta.js new file mode 100644 index 0000000..fd3e286 --- /dev/null +++ b/src/save/meta.js @@ -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;