Skip to main content

To simplify exif manipulations with python. Writing, reading, and more...

Project description

Build Status Coverage Status docs

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


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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

piexif-0.7.1-py2.py3-none-any.whl (16.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file piexif-0.7.1.zip.

File metadata

  • Download URL: piexif-0.7.1.zip
  • Upload date:
  • Size: 153.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for piexif-0.7.1.zip
Algorithm Hash digest
SHA256 ec7d5e53129d751f603683cdb86e0ce0798a41d16ca2467176965bc7a38cbf04
MD5 9d0a3b3c7141a8ee7ee43c5cedaf8c30
BLAKE2b-256 a971ebd6ea9c2eb8fe90cd5f49d0d9a3649d5f5c1381ca53a300437ef3510a34

See more details on using hashes here.

File details

Details for the file piexif-0.7.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for piexif-0.7.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ae52fbcdde73dc2301ede6bd52ec7981f5ec1b2f4f171112ab952b4f720fab8d
MD5 ab9ae03063258c412a4bde2401d33cdc
BLAKE2b-256 ffa8b0b0693d177c1faa7ee6ca4f1190ecfafed1bf064be5a3acf7bbf0f58d6a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page