Mutate Images Exif

JS
S
JavaScript

Tool to modify EXIF metadata in image files. Enables editing or removing camera, location, and other embedded information from photos.

1const exiftool = require('node-exiftool')
2const exiftoolBin = require('dist-exiftool')
3
4const updateDescriptions = async (basePath, images, csvData) => {
5  const ep = new exiftool.ExiftoolProcess(exiftoolBin)
6  await ep.open()
7
8  for (const image of images) {
9    let imageId = image.split('.')[0]
10    let rowMatch = await csvData.find(row => row.id === imageId)
11    if (rowMatch) {
12      ep.writeMetadata(`${basePath}/${image}`, {
13        Description: String(rowMatch.description).replace(/\n/g, '\r'),
14        Caption: String(rowMatch.description).replace(/\n/g, '\r'),
15      }, ['charset=UTF8', 'overwrite_original', 'E'])
16    }
17  }
18  await ep.close()
19}
20
21module.exports = updateDescriptions

Created on 4/8/2022