Pragmatism in the real world

Use ExifTool to remove private data in images

I’m a huge fan of ExifTool for manipulating EXIF data in images as it really is the Swiss Army knife for all things metadata related with images.

Recently, I wanted to strip some privacy-related metadata from some photos; specifically location, people and keywords. That is, I wanted to keep the title, the camera settings, the creator, and so on, but remove information that pertains to people and place.

This is the script that I wrote:

#!/usr/bin/env bash

# Remove all keywords, rating, people and location data
exiftool \
    -overwrite_original \
    -m \
    -r \
    -keywords= -Subject= \
    -Rating= \
    -RegionInfoMP= -RegionInfo= -imageregion= -PersonInImage= \
    -Location= -gps:all= -City= -State= -Sub-location= \
    -IPTCDigest= \

echo "All keywords, people and location data removed from $1"

To remove metadata fields from an image with ExifTool, you use the format -{NameOfField} flag and set it equal to nothing. To find the name of the fields you want to clear, use:

exiftool -J {filename}

This prints out all the metadata in JSON format which provides the internal field name that you need to use for the parameter flag.

I also set -r so that it will processes all images in a directory if I pass a directory name to this script. Also, note that I use -overwrite_original because I trust the tool and can always re-export the photo anyway. Use this flag at your own risk!

I added a little automation with Keyboard Maestro and now have a hotkey that I can use in Finder to strip this data from my image before sending it on.

Thoughts? Leave a reply

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