Piexif

A pure-Python library for reading, writing, inserting, and removing EXIF metadata in JPEG and WebP images.

Library
PyPI
v1.1.3
391stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
43/100Fair
Development Activity0
Maintenance20
Community72
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
66/100Good
Architecture60
Code Quality65
Innovation55
Learning Curve85

Piexif implements the EXIF specification entirely in Python, with no C extensions, giving it a small, portable footprint that runs anywhere CPython (or PyPy/IronPython) runs, including restricted environments like Google App Engine. Its API is deliberately small: load() parses EXIF data out of a file or byte string into a nested dict keyed by IFD (0th, Exif, GPS, 1st), dump() serializes such a dict back into EXIF bytes, and insert()/remove()/transplant() handle writing, stripping, or copying EXIF blocks between JPEG/WebP files without needing to decode the image itself.

Because it operates on raw EXIF bytes rather than decoded pixel data, Piexif is commonly paired with Pillow: Pillow can extract/embed the opaque EXIF blob, while Piexif provides structured read/write access to the individual tags inside it. The project has been stable and essentially feature-complete for several years, with infrequent commits reflecting a small, well-defined problem space rather than active feature growth.

What You Get

  • piexif.load(filename_or_bytes) returning EXIF data as a nested dict keyed by IFD (0th, Exif, GPS, 1st, Interop)
  • piexif.dump(exif_dict) to serialize an EXIF dict back into raw EXIF bytes for re-embedding
  • piexif.insert()/piexif.remove() to write or strip EXIF data directly on a JPEG/WebP file on disk
  • piexif.transplant() to copy EXIF data from one JPEG file to another without re-encoding
  • piexif.TAGS/piexif.ImageIFD/piexif.ExifIFD/piexif.GPSIFD constants and name lookups for every standard EXIF tag

Common Use Cases

  • Stripping EXIF/GPS metadata from user-uploaded photos before storage for privacy reasons
  • Reading camera/lens/GPS metadata from JPEGs for photo-management or geotagging applications
  • Writing or correcting EXIF fields (orientation, timestamps, resolution) after resizing or processing an image with Pillow
  • Copying EXIF metadata from an original photo onto a derived/edited version of the same photo

Under The Hood

Architecture - The package is organized as small, single-purpose modules under piexif/: _load.py (269 lines) parses the TIFF/EXIF byte structure into IFD dicts, _dump.py (346 lines) does the reverse serialization, _insert.py/_remove.py/_transplant.py handle the JPEG/WebP file-level operations (locating the APP1 marker and splicing bytes), and _exif.py (638 lines) holds the large static tag-definition tables (TAGS, ImageIFD, ExifIFD, GPSIFD) that everything else references. piexif/__init__.py is an 11-line facade re-exporting the public functions.

Tech Stack - Zero runtime dependencies, pure standard-library Python (struct, file I/O) — no Pillow, numpy, or C extension requirement, which is the library’s core value proposition. Packaged with classic setuptools/setup.py.

Code Quality - tests/s_test.py plus a tests/images/ fixture directory exercise round-trip load/dump/insert/remove/transplant behavior against real JPEG/WebP sample files; CI historically ran on both Travis (Linux) and AppVeyor (Windows) per the README badges. The tag-table modules are large but mechanically generated from the EXIF spec rather than hand-maintained logic, keeping the actual behavioral code compact.

API Design - The public surface is intentionally just five top-level functions plus tag-constant lookups, documented directly in the README with runnable examples; the nested-dict EXIF representation matches the spec’s own IFD structure closely, so users familiar with EXIF need almost no additional mental model to start reading/writing tags.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search