Every photo your iPhone captures contains embedded metadata—Exchangeable Image File Format (EXIF) data—that reveals more than just the image itself. This metadata includes GPS coordinates, device information, timestamps, and camera settings. For developers and power users handling sensitive photography or building privacy-focused applications, understanding how to strip this location data becomes essential.

This guide covers multiple methods to remove location metadata from iPhone photos, ranging from simple command-line tools to programmatic solutions suitable for automation pipelines.

Understanding iPhone Photo Metadata

When you capture a photo on an iPhone, iOS embeds extensive EXIF data within each image file. The most privacy-sensitive fields include:

This data persists even when you share photos through messaging apps or upload to cloud services. Removing metadata before sharing prevents unintended location exposure.

Method 1: Using exiftool (Command Line)

The industry-standard tool for metadata manipulation is Phil Harvey’s exiftool. Install it via Homebrew:

brew install exiftool

Strip all metadata from a single image:

exiftool -all= -overwrite_original photo.jpg

To strip only GPS data while preserving other metadata:

exiftool -gps:all= -overwrite_original photo.jpg

Batch process all JPEG files in a directory:

exiftool -all= -overwrite_original *.jpg

The -overwrite_original flag modifies files in place without creating backup copies. Remove this flag if you need backup versions.

Method 2: Python Script with Pillow

For developers building automated workflows, Python provides programmatic metadata removal. Install the required libraries:

pip install Pillow piexif

Create a script to strip GPS data:

#!/usr/bin/env python3
import os
import piexif
from PIL import Image

def remove_gps_data(image_path):
    """Remove GPS EXIF data from an image file."""
    try:
        exif_dict = piexif.load(image_path)
        
        # Remove GPS IFD (Interchangeable Field Directory)
        if 'GPS' in exif_dict:
            exif_dict['GPS'] = {}
        
        # Rebuild EXIF data without GPS
        exif_bytes = piexif.dump(exif_dict)
        
        # Save the cleaned image
        img = Image.open(image_path)
        img.save(image_path, "jpeg", exif=exif_bytes)
        
        print(f"Stripped GPS data from: {image_path}")
    except Exception as e:
        print(f"Error processing {image_path}: {e}")

def process_directory(directory_path):
    """Process all JPEG files in a directory."""
    for filename in os.listdir(directory_path):
        if filename.lower().endswith(('.jpg', '.jpeg')):
            filepath = os.path.join(directory_path, filename)
            remove_gps_data(filepath)

if __name__ == "__main__":
    import sys
    if len(sys.argv) > 1:
        process_directory(sys.argv[1])
    else:
        print("Usage: python strip_gps.py <directory>")

Run the script on a directory of photos:

python strip_gps.py /path/to/photos

Method 3: Using ImageMagick

ImageMagick offers another command-line approach for batch processing:

# Install ImageMagick
brew install imagemagick

# Strip all metadata
mogrify -strip photo.jpg

# Strip only GPS data while preserving other metadata
mogrify -sampling-factor 4:2:0 -strip -auto-orient \
  -interlace Plane -quality 85 \
  -define jpeg:remove-gps=true photo.jpg

The -define jpeg:remove-gps=true flag specifically targets GPS data while preserving color profiles and orientation.

Method 4: Shortcuts App (No-Code Solution)

For users preferring a native iOS solution, the Shortcuts app provides automation without scripting:

  1. Open Shortcuts → Create New Shortcut
  2. Add action: Select Photos
  3. Add action: Get EXIF Data (filter for GPS)
  4. Add action: Remove EXIF Metadata (select GPS only)
  5. Add action: Save to Photo Library

This shortcut can be run manually or scheduled via automation.

Method 5: macOS Automator Workflow

Build a drag-and-drop solution using Automator:

  1. Open AutomatorNew DocumentApplication
  2. Add Get Specified Finder Items
  3. Add Apply Quartz FiltersRemove Metadata
  4. Save as an app
  5. Drag photos onto the app icon to process them

Verification: Checking Removed Metadata

After processing, verify that GPS data is gone:

exiftool -gps photo.jpg

For a cleaned image, this command returns no GPS tags. You can also use:

exiftool -a -u photo.jpg | head -50

This shows all metadata including previously unknown tags, confirming removal.

Integration Examples

GitHub Actions Pipeline

Automate metadata stripping in CI/CD:

name: Strip Photo Metadata
on: [push]
jobs:
  strip-metadata:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install exiftool
        run: sudo apt-get install -y libimage-exiftool-perl
      - name: Strip GPS data
        run: |
          find ./photos -name "*.jpg" -exec exiftool -gps:all= -overwrite_original {} \;
      - uses: actions/upload-artifact@v4
        with:
          name: cleaned-photos
          path: ./photos

Renaming Scripts for Batch Processing

Combine stripping with organized file naming:

#!/bin/bash
# Process all JPEG files and rename with date prefix

for file in *.jpg *.jpeg; do
  [ -f "$file" ] || continue
  
  # Get date from EXIF
  date=$(exiftool -DateTimeOriginal -d "%Y%m%d_%H%M%S" -s -s -s "$file")
  
  # Strip GPS
  exiftool -gps:all= -overwrite_original "$file"
  
  # Rename with date prefix
  if [ -n "$date" ]; then
    mv "$file" "${date}_${file}"
  fi
done

Summary

Removing location metadata from iPhone photos protects privacy when sharing images. Whether you prefer command-line tools like exiftool, programmatic solutions with Python, or native iOS shortcuts, multiple approaches exist for every skill level.

For developers building photo applications, integrating metadata stripping into your pipeline ensures user privacy by default. The exiftool approach offers the most flexibility, while Python scripts provide customization for specific use cases.

Always verify removal with exiftool after processing—assumptions about data removal can lead to unintended privacy exposure.

Built by theluckystrike — More at zovo.one