Closed ndtreviv closed 5 years ago
In the end I did this:
return new Promise((resolve, reject) => {
try {
ep.open()
.then(pid => log.info("Started exiftool process %s", pid))
.then(() => {
resolve(
Promise.all(
filePaths.map(filePath => {
log.info("Extracting exif from image: " + filePath);
return ep.readMetadata(filePath, OPTIONS).then(async data => {
const hashes = await calculateHashes(filePath);
if (data.error) { log.warn(data.error); }
return {
filePath,
error: data.error,
data:
data.data && data.data.length
? { ...data.data[0], ...hashes }
: hashes
};
});
})
)
);
})
.then(() => ep.close())
.then(() => log.info("Closed exiftool"))
.catch(error => {
log.error(error);
log.info("Error 1", error);
reject(error);
});
}catch (e) {
log.info("Error 1", e);
}
});
For example:
Input is a list of files not necessarily in the same directory.
Output is an array of exif
{...}
objects.Something like: