To simplify exif manipulations with python. Writing, reading, and more...
Project description
This is a renamed project from Pyxif.
To simplify exif manipulations with python. Writing, reading, and more…
Piexif isn’t a wrapper. To everywhere with Python.
Install
‘easy_install’
$ easy_install piexif
or ‘pip’
$ pip install --pre piexif
or download .zip, extract it and run
$ python setup.py install
Functions
load - get exif as dict from file(JPEG and TIFF) dump - converts dict to exif bytes insert - inserts exif bytes to JPEG remove - removes exif from JPEG transplant - transplants exif to another JPEG
How to Use
zeroth_ifd = {piexif.ZerothIFD.Make: u"Canon", piexif.ZerothIFD.XResolution: (96, 1), piexif.ZerothIFD.YResolution: (96, 1), piexif.ZerothIFD.Software: u"paint.net 4.0.3", } exif_ifd = {piexif.ExifIFD.DateTimeOriginal: u"2099:09:29 10:10:10", piexif.ExifIFD.LensMake: u"LensMake", piexif.ExifIFD.Sharpness: 65535, piexif.ExifIFD.LensSpecification: ((1, 1), (1, 1), (1, 1), (1, 1)), } gps_ifd = {piexif.GPSIFD.GPSVersionID: (2, 0, 0, 0), piexif.GPSIFD.GPSAltitudeRef: 1, piexif.GPSIFD.GPSDateStamp: u"1999:99:99 99:99:99", } # dump and insert exif_bytes = piexif.dump(zeroth_ifd, exif_ifd, gps_ifd) piexif.insert(exif_bytes, "in.jpg") # with Pillow from PIL import Image im = Image.open("in.jpg") im.thumbnail((100, 100), Image.ANTIALIAS) im.save(output_file, exif=exif_bytes) # load zeroth_dict, exif_dict, gps_dict = piexif.load("in.jpg") # remove piexif.remove("in.jpg") # transplant piexif.transplant("exif_src.jpg", "image.jpg")
on GoogleAppEngine
jpg_data = self.request.get("jpeg") output = io.BytesIO() # insert piexif.insert(exif_bytes, jpg_data, output) # load zeroth_dict, exif_dict, gps_dict = piexif.load(jpg_data) # remove piexif.remove(jpg_data, output) # transplant piexif.transplant(jpg_data1, jpg_data2, output)
Tag Name and Value Type
Each exif tag has appropriate type of the value. BYTE, ASCII, SHORT, or…
See the document of Exif.
Some examples are shown below. If value type is number and count is two or more,
use tuple.
BYTE: {GPSIFD.GPSAltitudeRef: 1} ASCII: {ZerothIFD.Make: u"Make"} SHORT: {ZerothIFD.ResolutionUnit: 65535} SHORT(count:3): {ZerothIFD.BitsPerSample: (24, 24, 24)} LONG: {ZerothIFD.JPEGInterchangeFormatLength: 4294967295} RATIONAL: {ZerothIFD.XResolution: (4294967295, 1)} UNDEFINED: {ExifIFD.OECF: b"\xaa\xaa\xaa\xaa\xaa\xaa"} SRATIONAL(count:3): {ZerothIFD.BlackLevelDeltaH: ((1, 1), (1, 1), (1, 1))}
Depends on
Piexif doesn’t depend on any 3rd module.
Environment
Tested on Python 2.7, 3.3, 3.4, pypy, and pypy3.
Piexif would run even on IronPython.
License
This software is released under the MIT License, see LICENSE.txt.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
piexif-0.7.1.zip
(153.5 kB
view hashes)
Built Distribution
piexif-0.7.1-py2.py3-none-any.whl
(16.5 kB
view hashes)
Close
Hashes for piexif-0.7.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae52fbcdde73dc2301ede6bd52ec7981f5ec1b2f4f171112ab952b4f720fab8d |
|
MD5 | ab9ae03063258c412a4bde2401d33cdc |
|
BLAKE2b-256 | ffa8b0b0693d177c1faa7ee6ca4f1190ecfafed1bf064be5a3acf7bbf0f58d6a |