Skip to content

Instantly share code, notes, and snippets.

@pirosuke
Created January 21, 2019 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pirosuke/e536da3b89797c5f1d801cff5d3efa3b to your computer and use it in GitHub Desktop.
Save pirosuke/e536da3b89797c5f1d801cff5d3efa3b to your computer and use it in GitHub Desktop.
A Sample Script To Remove EXIF Data From Image File.
const path = require('path');
const fs = require('fs');
const piexif = require('piexifjs');
function removeExifFromImage(srcImgPath, destImgPath) {
const imgData = fs.readFileSync(srcImgPath).toString('binary');
const newImgData = piexif.remove(imgData);
fs.writeFileSync(destImgPath, newImgData, 'binary');
}
async function main() {
const srcDirPath = 'SOURCE_DIRECTORY_PATH';
const destDirPath = 'DEST_DIRECTORY_PATH';
const srcFileList = fs.readdirSync(srcDirPath);
for (const srcFileName of srcFileList) {
if (!srcFileName.endsWith('.JPG')) {
continue;
}
console.log('Processing ', srcFileName, '...');
try {
removeExifFromImage(path.join(srcDirPath, srcFileName), path.join(destDirPath, srcFileName));
} catch (err) {
console.log(err);
}
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment