Skip to content
forked from hMatoba/Piexif

Exif manipulation with pure python script.

License

Notifications You must be signed in to change notification settings

uploadcare/Piexif

This branch is 30 commits ahead of hMatoba/Piexif:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

2250d0c · May 10, 2023
Jul 1, 2019
Feb 2, 2022
Feb 2, 2022
Sep 13, 2014
Jan 3, 2018
Dec 27, 2019
Feb 3, 2015
Sep 2, 2016
Mar 11, 2019
Mar 11, 2019
Aug 7, 2016
Jan 3, 2018
Aug 20, 2017
May 10, 2023
Mar 11, 2019

Repository files navigation

Piexif

Build Status Windows Build Coverage Status docs

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

Install

'easy_install':

$ easy_install piexif

or 'pip':

$ pip install piexif

or download .zip, extract it. Put 'piexif' directory into your environment.

Why Choose Piexif

How to Use

There are only just five functions.

  • load(filename) - Get exif data as dict.
  • dump(exif_dict) - Get exif as bytes.
  • insert(exif_bytes, filename) - Insert exif into JPEG, or WebP.
  • remove(filename) - Remove exif from JPEG, or WebP.
  • transplant(filename, filename) - Transplant exif from JPEG to JPEG.

Example

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])

With PIL(Pillow)

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)

Environment

Tested on Python 2.7, 3.5+ and PyPy3. Piexif would run even on IronPython. Piexif is OS independent and can run on Google App Engine.

License

This software is released under the MIT license, see LICENSE.txt.

About

Exif manipulation with pure python script.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.9%
  • Batchfile 0.1%