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.
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
Run checks: pytest -v tests/test_inspector.py4. 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
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.
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.
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.