Piexif
A pure-Python library for reading, writing, inserting, and removing EXIF metadata in JPEG and WebP images.
Repository Health
Technical Analysis
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-embeddingpiexif.insert()/piexif.remove()to write or strip EXIF data directly on a JPEG/WebP file on diskpiexif.transplant()to copy EXIF data from one JPEG file to another without re-encodingpiexif.TAGS/piexif.ImageIFD/piexif.ExifIFD/piexif.GPSIFDconstants 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.
Used by 2 apps in this directory
clarity-upscaler
AI Design Tools · Design Tools
Free open-source AI image upscaler reaching 13K resolution using Stable Diffusion, ControlNet, and Tiled Diffusion — a self-hostable alternative to Magnific.
Jaaz
AI Design Tools · AI Agents
Open-source AI creative agent that turns visual sketches and canvas gestures into images and videos — no text prompts required.