Skip to content

Photo Privacy Scrubber

In plain English

Removes hidden camera details, capture dates, and GPS location coordinates safely from folders of photos before you share them online.

A Python 3.12 and Pillow inspection and privacy utility reading nested EXIF/GPS dictionaries and exporting format-safe metadata-free copies.

1. Why I built it

Built to inspect and strip embedded camera metadata safely across different image modes without corrupting colours or overwriting sources.

Problem being solvedNaive canvas copying drops palette lookup tables on indexed images and fails converting alpha PNGs to JPEG outputs.

2. How it works

Implemented `ImageInspectionReport`, `inspect_image()`, and `strip_metadata_to_copy()` in `src/image_metadata/inspector.py`.

Photographs carry camera identifiers, software metadata, timestamps, and nested GPS sub-IFD entries (`tag 34853`). EXIF Metadata Scrubber parses those headers into `ImageInspectionReport` dataclasses and writes clean scrubbed files.

Copying raw canvases naively drops palette tables on indexed (`P`-mode) images and throws errors when exporting RGBA PNGs to JPEG. `strip_metadata_to_copy()` preserves palette transparency, infers the output encoder from the target suffix, and flattens RGBA channels onto white when writing JPEG.

Canonical path verification (`source.resolve() == target.resolve()`) guarantees originals are never clobbered in place.

3. Output & Source Specimen

Scrub Summary Return Schema

01strip_metadata_to_copy(source_path, output_path) -> dict:
02 source_path : str (preserved untouched via canonical resolve check)
03 output_path : str (inferred format: JPEG/PNG/WEBP/BMP/TIFF)
04 removed_exif_field_count : int (EXIF count inspected before scrub)
05 removed_gps_data : bool (IFD tag 34853 presence)
06 output_has_exif : bool (re-verified via inspect_image(target) == False)
Verification dictionary returned and post-checked by strip_metadata_to_copy()Run checks: pytest -v tests/test_inspector.py

4. Design Decisions & Challenges

Key Design Decisions

  • 01.Converted palette (`P`) images safely (`RGBA` or `RGB`) so indexed palette entries stay intact.
  • 02.Flattened `RGBA`/`LA`/`PA` images onto a white RGB background before JPEG saving based on target extension.
  • 03.Asserted canonical path separation and `after.has_exif == False` before returning.

Edge Cases Handled

  • Reading nested GPS coordinates cleanly in Pillow 10+ via `exif_data.get_ifd(34853)`.

5. Testing & Limits

Automated Checks

Verified with 7 pytest checks in `tests/test_inspector.py` testing nested EXIF/GPS parsing and stripping, `ImageOps.exif_transpose()` orientation normalisation, palette/RGBA/CMYK conversions, recursive directory mirroring, CLI error handling, and overwrite protection.

Current Limits & Next Steps

  • Re-encoding image pixels alters lossy JPEG frames; byte-level APP1 marker removal would allow lossless JPEG stripping.

6. Key Takeaways

What building Photo Privacy Scrubber reinforced

Safe metadata scrubbing requires explicit colour-mode and transparency handling per output format rather than blindly cloning image buffers.

  • — 7 pytest checks and Ruff lint pass cleanly.
  • — Source hosted at github.com/16lv/exif-metadata-scrubber.

Recent Activity

Latest repository updates

All changes for 16lv/exif-metadata-scrubber

fix: auto-transpose EXIF orientation before stripping and handle CLI errors cleanly

Applied ImageOps.exif_transpose() ahead of pixel recreation so rotated portrait photos save upright when EXIF headers are stripped.

2026-11-247cdc038

feat: support recursive directory EXIF scrubbing and CLI flag

Updated scrub_directory() to mirror nested folder trees when recursive=True is passed via API or exif-scrubber scrub-dir.

2026-11-231d15df8

Add python -m image_metadata runner and verify editable install in CI

Committed directly to exif-metadata-scrubber (main) · Removes hidden camera details, capture dates, and GPS location coordinates safely from folders of photos before you share them online.

2026-11-21765f7f8