How to Strip Metadata from Images Using ImageMagick on Mac

If you want to remove any identifying metadata information from your photos before posting them online, ImageMagick offers a quick and easy way to do it. It’s especially good when paired with macOS Folder Actions to do it automatically when you drop photos into a designated folder.

Screenshot of macOS Automator Folder Action for stripping metadata automatically
Text & Photos By David Coleman
Last Revised & Updated:

I MAY get commissions for purchases made through links in this post.

Metadata in photos can contain a variety of information, from the type of camera used to the exact GPS location where a photo was taken. All of that is saved silently and automatically by the camera when you take the shot.

This information can sometimes be very useful, and much of it is pretty innocuous. That you used a shutter speed of 1/125 isn’t really going to be used against you.

But some of it might include identifying information that you don’t want to share when you share images online. Things like GPS location information, for example. So you may want to strip this information to preserve privacy.

There are a number of tools that are also good for stripping out metadata such as location information, and I discuss some of the good alternatives below. But if you’re already using ImageMagick in your workflow, and especially if you’re using Mac Folder Actions to automatically process watched folders, it can be an especially good option, because you can include the command into other ImageMagick operations.

Why Use ImageMagick?

ImageMagick is not only powerful for converting and modifying images but also offers precise control over metadata. Here’s why it’s particularly useful for privacy-focused tasks:

  • It’s capable of batch processing, making it suitable for handling large numbers of files efficiently.
  • It allows for scripting and automation, which can be combined with macOS Folder Actions for automatic processing.
  • It’s a command-line tool, which can be faster and more resource-efficient than GUI applications for certain tasks.
  • And, crucially, stripping metadata from photos is handled by ImageMagick in such a way that it doesn’t re-encode recompress the image, which means there’s no loss in image quality.

For the purposes of stripping metadata from images, I’d argue that EXIFtool is an even better choice. And I’ll be doing a separate guide to using that. But if you don’t want to install yet another command-line script toolkit and area already using ImageMagick, then ImageMagick is still a very good way to do it.

There’s also SIPS, which is an image toolkit that is baked into macOS and therefore doesn’t require any installation at all. And it does have a basic functionality for stripping metadata. But the reason I don’t use it for that is that I’ve heard discussion about whether it reliably can remove all metadata and that it might leave some behind in some circumstances and with some more complex metadata structure. Whether there’s anything to that, I don’t know. But since there are other trusted options available, like ExifTool and ImageMagick, I prefer to stick with those.

I’m going to assume here that you already have ImageMagick installed on your Mac. If you don’t, I’ve created a step-by-step guide to installing ImageMagick on Mac to get you up and running in no time.

Stripping Metadata from a Single Image

NB: This command will modify the original file, so make a backup if needed.

To remove metadata from a single image file, first navigate to the folder that the image is in and then type:

magick mogrify -strip input.jpg

Replace input.jpg with your file’s name.

Batch Stripping Metadata from Images

Again, this will replace the original files, so be sure to work on copies or have backups.

To remove metadata from all images in a directory:

for file in *.{jpg,jpeg,png,gif,webp,heic,heif}; do magick mogrify -strip "$file"; done

This script will process all specified image files in the current directory.

Automating Metadata Removal with macOS Folder Actions

Setting up a watched folder with Automator allows you to automatically strip metadata from any image dropped into it.

I find this especially useful, especially if it’s something you find yourself doing often. Once it’s set up, it’s just so quick to use.

And setting it up is quick and easy, thanks to Mac’s built-in Automator and Folder Actions functionality.

Here’s the outline:

  1. Create a new Folder Action in Automator.
  2. Use “Run Shell Script” with Pass input as as arguments.
  3. Set the Shell to /bin/zsh.
  4. Insert the following script:
for f in "$@"
    /usr/local/bin/magick mogrify -strip "$f"

You should end up with something like this. In this case, the folder I’m attaching it to is called “Metadata stripped”. (I have a cluster of folders for common image tasks such as converting from one format to another, resizing, etc. And one of those is for stripping metadata.)

Screenshot of macOS Automator Folder Action for stripping metadata automatically

With this Automator action, any image placed in the watched folder will have its metadata stripped without altering the image quality. It will overwrite the files with the new version, so make sure to be working with copies or have backups.

Alternatives to ImageMagick to Strip Metadata from Photos

While ImageMagick is a powerful tool, there are other applications that can remove metadata from images. They offer various features and interfaces that might be better suited to different workflows or preferences. ImageOptim, for example, is particularly user-friendly with its drag-and-drop functionality, while ExifTool offers extensive capabilities for those who need to edit or remove specific metadata fields.

  • ImageOptim: A free GUI tool that can also compress images without losing quality. Its focus is on optimizing image files, but part of that is functionality to strip out metadata.
  • ExifTool: A highly customizable command-line application specifically designed for reading, writing, and editing meta information in a wide variety of files. This is more specialized and even better suited to the job. I’ll put together a separate guide to using that, but since it requires a separate process of setting it up, it might not always be as convenient if you’re already using ImageMagick for other tasks.
  • EXIFPurge: This a one-trick pony drag-and-drop app, but it does what it says and does it well.

Things Worth Knowing

This is going to strip everything in metadata fields. For instance, if you’ve exported your photos from Lightroom with the “only Copyright” option, that removes most metadata but leaves a copyright notice. This process is going to even remove that.

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.

Stay tuned: I’ll add them here as I create new ones.

Profile photo of David Coleman | Have Camera Will Travel | Washington DC-based Professional Photographer

Text & Photos by David Coleman

I'm a professional photographer based in Washington DC. Seven continents, up mountains, underwater, and a bunch of places in between. I've been shooting for 30+ years, and my my photos and time-lapse videos have appeared in a bunch of different publications from major newspapers to magazines and books, billboards, TV shows, professional sports stadiums, museums, and even massive architectural scrims covering world-famous buildings while they're being renovated. You can see some of my travel photography here and here.

Leave a Comment