Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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')) {
console.log('Processing ', srcFileName, '...');
try {
removeExifFromImage(path.join(srcDirPath, srcFileName), path.join(destDirPath, srcFileName));
} catch (err) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment