Exif Remover with exiftool

Hi! Exif data are sometimes considered as “sensitive data”. If you want to share your photo, but you don’t want to give to companies additional information about the location where these photo where taken, or additional information about your equipment, you should remove Exif data. For this reason, I made a simple bash script that removes all Exif entries.

The script has two options:

  • -s: show all Exif entries
  • -m: remove all Exif entries and leaves only the most important

For example, you can modify a jpg with this command:
./ExifRemover.sh -m MyImg.jpg

And this is the script:

#! /bin/bash

function usage {
	echo "usage: $0 -ms path_of_file"
	echo "	-m to remove useless exif entries"
	echo "	-s to show current exit entries"
	exit -1
}

if [ $# != 2 ]; then
	usage
fi

OP=$1
SRC=$2

if [ ! -f $SRC ]; then
	echo "error: file not found"
	exit -2
fi

if [ $OP = "-m" ]; then

	cp "$SRC" "$SRC"."_tmp"
	exiftool -all= "$SRC"
	exiftool -overwrite_original
			-TagsFromFile "$SRC"."_tmp"
			-ExposureTime
			-FNumber
			-ExposureProgram
			-ISO
			-DateTimeOriginal
			-CreateDate
			-ExposureCompensation
			-MaxApertureValue
			-MeteringMode
			-LightSource
			-Flash
			-FocalLength
			-SubSecTime
			-SubSecTimeOriginal
			-SubSecTimeDigitized
			-ColorSpace
			-ExifImageWidth
			-ExifImageHeight
			-SensingMethod
			-CustomRendered
			-ExposureMode
			-WhiteBalance
			-DigitalZoomRatio
			-FocalLengthIn35mmFormat
			-SceneCaptureType
			-GainControl
			-Contrast
			-Saturation
			-Sharpness
			-SubjectDistanceRange
			-GPSVersionID
			-GPSLatitudeRef
			-GPSLatitude
			-GPSLongitudeRef
			-GPSLongitude
			-Make
			-Model
		"$SRC"

	exiftool -delete_original! "$SRC"
	rm -f "$SRC"."_tmp"

else
	if [ $OP = "-s" ]; then
		exiftool "$SRC"
	else
		usage
	fi
fi

Download: ExifRemover.sh

Leave a Reply

Your email address will not be published. Required fields are marked *