Skip to main content

Read and modify image EXIF metadata using Python.

Project description

https://www.gitlab.com/TNThieding/exif/badges/master/pipeline.svg https://www.gitlab.com/tnthieding/exif/badges/master/coverage.svg Documentation Status https://img.shields.io/badge/code%20style-black-000000.svg Checked with mypy

Read and modify image EXIF metadata using Python without any third-party software dependencies. For example, batch process image metadata using a Python script.

Quick Start

Open an image with EXIF metadata using the Python open() built-in function. Ensure the binary mode flag is set. Pass this image file object into the exif.Image class:

>>> from exif import Image
>>> with open('grand_canyon.jpg', 'rb') as image_file:
...     my_image = Image(image_file)
...
>>> my_image.has_exif
True

List EXIF attributes using the Python dir() builtin function:

>>> dir(my_image)
['<unknown EXIF tag 59932>', '<unknown EXIF tag 59933>', '_exif_ifd_pointer', '_gps_ifd_pointer', '_segments', 'aperture
_value', 'brightness_value', 'color_space', 'components_configuration', 'compression', 'datetime', 'datetime_digitized',
'datetime_original', 'exif_version', 'exposure_bias_value', 'exposure_mode', 'exposure_program', 'exposure_time', 'f_
number', 'flash', 'flashpix_version', 'focal_length', 'focal_length_in_35mm_film', 'get', 'get_file', 'get_thumbnail',
'gps_altitude', 'gps_altitude_ref', 'gps_datestamp', 'gps_dest_bearing', 'gps_dest_bearing_ref', 'gps_horizontal_
positioning_error', 'gps_img_direction', 'gps_img_direction_ref', 'gps_latitude', 'gps_latitude_ref', 'gps_longitude',
'gps_longitude_ref', 'gps_speed', 'gps_speed_ref', 'gps_timestamp', 'has_exif', 'jpeg_interchange_format', 'jpeg_
interchange_format_length', 'lens_make', 'lens_model', 'lens_specification', 'make', 'maker_note', 'metering_mode',
'model', 'orientation', 'photographic_sensitivity', 'pixel_x_dimension', 'pixel_y_dimension', 'resolution_unit',
'scene_capture_type', 'scene_type', 'sensing_method', 'shutter_speed_value', 'software', 'subject_area', 'subsec_time_
digitized', 'subsec_time_original', 'white_balance', 'x_resolution', 'y_and_c_positioning', 'y_resolution']

Access EXIF metadata tags using Python attribute notation:

>>> # Read tags with Python "get" notation.
>>> my_image.gps_latitude
(36.0, 3.0, 11.08)
>>> my_image.gps_longitude
(112.0, 5.0, 4.18)
>>> my_image.model
'iPhone 7'
>>>
>>> # Modify tags with Python "set" notation.
>>> my_image.make = "Python"
>>>
>>> # Delete tags with Python "del" notation.
>>> del my_image.gps_latitude
>>> del my_image.gps_longitude
>>>
>>> # Add new tags with Python "set" notation.
>>> from exif import LightSource
>>> my_image.light_source = LightSource.DAYLIGHT

Write the image with modified EXIF metadata to an image file using open() in binary write mode:

>>> with open('modified_image.jpg', 'wb') as new_image_file:
...     new_image_file.write(my_image.get_file())
...

Refer to the usage page for information and examples of alternative ways to access EXIF tags (e.g. with index/item syntax or with methods).

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

exif-1.1.0.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

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

exif-1.1.0-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file exif-1.1.0.tar.gz.

File metadata

  • Download URL: exif-1.1.0.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for exif-1.1.0.tar.gz
Algorithm Hash digest
SHA256 18d4d2fd996e791aea08ab53c2e6b53bcfcf5992e222722e03d0104939fca878
MD5 cdfe0dc3ae0cb2c8b3d8ff38db94346c
BLAKE2b-256 52e1c65250a152bd3aff39f1aad8f77b9b051ecee4f9eb38aa0a3736f6af2382

See more details on using hashes here.

File details

Details for the file exif-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: exif-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for exif-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d018e970188d78fb0425bc30fdb8341ff69f4b4305ef9732c352e5bb96aa3765
MD5 99859b2f7108a926a24722122346c330
BLAKE2b-256 63e04da2157ac02f3cf6b73395cf834c7bf691c140b9bf0726ee7ba18728c614

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