To simplify exif manipulations with Python. Writing, reading, and more... Piexif is pure Python. To everywhere with Python.
Document: http://piexif.readthedocs.org/en/latest/
Online demo: http://piexif-demo.appspot.com/demo
'easy_install':
$ easy_install piexif
or 'pip':
$ pip install piexif
or download .zip, extract it. Put 'piexif' directory into your environment.
- Pure Python. So, it runs everywhere where Python runs.
- Easy exif manipulations. Read, write, remove...
- Documented. http://piexif.readthedocs.org/en/latest/
There are only just five functions.
- load(filename) - Get exif data as dict.
- dump(exif_dict) - Get exif as bytes to save with JPEG.
- insert(exif_bytes, filename) - Insert exif into JPEG.
- remove(filename) - Remove exif from JPEG.
- transplant(filename, filename) - Transplant exif from JPEG to JPEG.
exif_dict = piexif.load("foo1.jpg") for ifd in ("0th", "Exif", "GPS", "1st"): for tag in exif_dict[ifd]: print(piexif.TAGS[ifd][tag]["name"], exif_dict[ifd][tag])
from PIL import Image import piexif im = Image.open(filename) exif_dict = piexif.load(im.info["exif"]) # process im and exif_dict... w, h = im.size exif_dict["0th"][piexif.ImageIFD.XResolution] = (w, 1) exif_dict["0th"][piexif.ImageIFD.YResolution] = (h, 1) exif_bytes = piexif.dump(exif_dict) im.save(new_file, "jpeg", exif=exif_bytes)
Tested on Python 2.7, 3.3, 3.4, 3.5, 3.6 and pypy3. Piexif would run even on IronPython. Piexif is OS independent and can run on Google App Engine.
This software is released under the MIT license, see LICENSE.txt.