https://github.com/hMatoba/Piexif
Exif manipulation with pure python script.
https://github.com/hMatoba/Piexif
exif jpeg python webp
Last synced: 9 months ago
JSON representation
Exif manipulation with pure python script.
- Host: GitHub
- URL: https://github.com/hMatoba/Piexif
- Owner: hMatoba
- License: mit
- Created: 2014-09-13T01:54:07.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-11-22T15:55:08.000Z (over 2 years ago)
- Last Synced: 2024-12-01T18:09:32.007Z (over 1 year ago)
- Topics: exif, jpeg, python, webp
- Language: Python
- Size: 2.79 MB
- Stars: 373
- Watchers: 17
- Forks: 83
- Open Issues: 55
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-privacy - Piexif
README
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
-----------------
- Pure Python. So, it runs everywhere where Python runs.
- Easy exif manipulations. Read, write, remove...
- Documented. http://piexif.readthedocs.org/en/latest/
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.
.. |Build Status| image:: https://api.travis-ci.org/hMatoba/Piexif.svg?branch=master
:target: https://travis-ci.org/hMatoba/Piexif
.. |Windows Build| image:: https://ci.appveyor.com/api/projects/status/github/hMatoba/Piexif?branch=master&svg=true
:target: https://ci.appveyor.com/project/hMatoba/piexif
.. |Coverage Status| image:: https://coveralls.io/repos/hMatoba/Piexif/badge.svg?branch=master
:target: https://coveralls.io/r/hMatoba/Piexif?branch=master
.. |docs| image:: https://readthedocs.org/projects/piexif/badge/?version=latest
:target: https://readthedocs.org/projects/piexif/