Digital photos inherently carry a trove of metadata, ranging from the camera model used and perhaps even to the precise GPS coordinates where they were captured. This latter is especially true with photos captured by smartphone cameras. This data is embedded automatically and discreetly by your camera at the moment you take the photo.
While often this metadata can be quite benign or even helpful—knowing your aperture setting or shutter speed, for instance, isn’t usually sensitive information—there are instances where it might include details you’d rather not broadcast or share online.
This is particularly true for data like the GPS location, which could inadvertently reveal your whereabouts, your home address, or habits when you share your images online. Or you might have stock agency keywords in there. Or notes or information about clients.
So, for the sake of privacy, you might prefer to scrub this data from your files before sharing them.
Table of Contents
Why Use ExifTool to Strip Metadata?
There are quite a few ways to tackle this.
I’ve previously posted a guide to stripping image metadata with the ImageMagick command-line tool on Mac. And macOS comes with a built-in command-line toolset called SIPS that has this functionality. Another good (and free) tool for this on Mac is ImagOptim. It also has the benefit of a user-friendly graphical user interface.
So why use ExifTool for this? After all, it does involve installing another command-line tool on your Mac. While that’s not hard to do–and I have a step-by-step guide on how to install ExifTool on Mac separately–it is another few steps.
So, from the outset, I’ll say that this makes most sense if it’s something you do fairly often as part of your photography workflow. It makes much less sense for one-off or just occasional use.
But here are the main reasons I use it for this:
- It’s the gold standard for wrangling image metadata. That means it’s thorough.
- Both ImageMagick and SIPS are good options for this, although I do have some lingering uncertainty about their thoroughness for this specific task. While I don’t have any examples of failures to point to, I have heard discussion of instances where they’ve missed metadata in some circumstances.
- It’s excellent for batch processing, and it works quickly and efficiently on large numbers of images.
- It combines nicely alongside both ImageMagick and macOS Folder Actions, making possible very useful workflow enhancements like creating drop folders for automatically stripping metadata from all the images you drop into the folder.
- While I’m focusing here on wiping all metadata from the images, you can actually be very precise about which metadata fields to clear and which to retain (or modify).
- Wiping the metadata with ExifTool doesn’t involve re-encoding the file, which means there’s no loss of image quality.
- Why not? It’s no harder to use than ImageMagick or SIPS, it’s also free, and you can have confidence that it’s thorough and reliable.
So here’s a guide to various commands and scripts you can use to remove all the metadata from images using ExifTool. I’ll start with the most basic versions of the command, and we’ll work up to integrating it with a watch folder action on Mac.
NB: I’m assuming here that you already have ExifTool installed. If no, I have a straightforward guide here.
First, A Heads Up
Before we start, there are two important things to note:
- In most of the examples below, the operations overwrite the input files. So be sure to be working on copies.
- These remove the ICC color profile. If you’re using sRGB, you might never notice, because many apps and browsers just assume sRGB if they can’t find one. But if you’re using other color profiles, such as sending images to a print lab or press, you might want to use the option to preserve the color profile (more on that below).
Stripping Metadata from a Single Image
To remove metadata from a single image, navigate to the folder containing the image and execute:
exiftool -all= -overwrite_original input.jpg
Replace input.jpg
with your file’s name. This command will remove all metadata from the file.
Batch Stripping Metadata from Images
To remove metadata from all images in a directory:
for file in *; do
if exiftool -q -if "$file" >/dev/null; then
exiftool -all= -overwrite_original "$file"
fi
done
This command processes all specified image files in the current directory, stripping their metadata and color profiles.
If you want to remove all metadata except the color profile, use this instead.
for file in *; do
if exiftool -q -if "$file" >/dev/null; then
exiftool -all= -icc_profile:all -overwrite_original "$file"
fi
done
-all=
tells ExifTool to remove all metadata.-icc_profile:all
is an exception to the previous command, instructing ExifTool to keep the ICC profile data intact.-overwrite_original
modifies the original file without creating backup files.
Save Output Files in a Subfolder
Instead of overwriting the input files, you can instead save the output files to a subfolder. In this case, it’s called “Stripped.”
for file in *; do
if exiftool -q -if "$file" >/dev/null; then
mkdir -p Stripped
outfile="Stripped/${file}"
exiftool -all= -icc_profile:all -o "$outfile" "$file"
fi
done
Add Copyright & Credit
You can also add copyright and credit metadata back in. This is an imperfect process because some image types and apps use different fields for these, but here’s a starting point to get the idea. You’d obviously want to change the values to your own.
current_year=$(date +"%Y")
for file in *; do
if exiftool -q -if "$file" >/dev/null; then
exiftool -m -all= -overwrite_original "$file"
exiftool -overwrite_original \
-Copyright="© $current_year David Coleman." \
-Creator="David Coleman" \
-Author="David Coleman" \
-Credit="Photo by David Coleman" \
"$file"
fi
done
Automating Metadata Removal with macOS Folder Actions
Setting up an automated process using macOS Folder Actions allows you to strip metadata from any image dropped into a specified folder. If you find yourself having to do this often, it’s a really useful workflow tool. It only takes a minute to set it up, and then it’s ready for reuse anytime you want to drop images into that folder.
Here’s how to set it up:
- Create a new Folder Action in Automator
- Choose “New Document.”
- Select “Folder Action” as the type of document.
- Assign the Folder Action to the desired folder.
- Use “Run Shell Script”
- With “Pass input” as
as arguments
. - Set the Shell to
/bin/zsh
. - Insert the script:
- With “Pass input” as
for f in "$@"
do
exiftool -all= -overwrite_original "$f"
done
- Save the Action
- Give it a descriptive name.
With this setup, any image placed in the watched folder will automatically have its metadata stripped. And, again, this is going to replace the input files, so be sure to working on copies.
And, of course, you can customize the script in all sorts of ways, such as adding copyright and credit, combining with ImageMagick transformations such as resizing or adding a watermark, and even extending the Automator action to do things like attach the images to an email and send them to a designated email address.
Alternatives to ImageMagick for Metadata Stripping
While ExifTool is a specialized tool for metadata manipulation, there are other options you might consider. And if this is something you need to do only occasionally, these probably make more sense.
- ImageOptim: A free GUI tool for image optimization that also strips metadata.
- EXIFPurge: A simple, user-friendly application for removing metadata. Paid app that’s available through the Mac App Store.
Useful ImageMagick Tasks for Photographers
I’ve put together some separate guides with ImageMagick recipes for particular tasks that I’ve found useful in a photography workflow.
- How to Convert to AVIF with ImageMagick
- How to Convert to WebP with ImageMagick
- How to Strip all Metadata from Images using ImageMagick
- How to Add a Plain Border to Images using ImageMagick
- How to Create a Contact Sheet with ImageMagick
Stay tuned: I’ll add them here as I create new ones.