mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 09:44:31 +03:00
Added Exif code examples
This commit is contained in:
parent
074c6afdc7
commit
a8e03e4dab
|
@ -1433,7 +1433,7 @@ class Image:
|
||||||
|
|
||||||
def getexif(self):
|
def getexif(self):
|
||||||
"""
|
"""
|
||||||
Gets EXIF data of the image.
|
Gets EXIF data from the image.
|
||||||
|
|
||||||
:returns: an :py:class:`~PIL.Image.Exif` object.
|
:returns: an :py:class:`~PIL.Image.Exif` object.
|
||||||
"""
|
"""
|
||||||
|
@ -3607,18 +3607,36 @@ atexit.register(core.clear_cache)
|
||||||
|
|
||||||
class Exif(MutableMapping):
|
class Exif(MutableMapping):
|
||||||
"""
|
"""
|
||||||
Exif class provides read and write access to EXIF image data.
|
This class provides read and write access to EXIF image data::
|
||||||
|
|
||||||
Only basic information is available on the root level, in Exif object
|
from PIL import Image
|
||||||
itself. In order to access the rest, obtain their respective IFDs using
|
im = Image.open("exif.png")
|
||||||
:py:meth:`~PIL.Image.Exif.get_ifd` method and one of
|
exif = im.getexif() # Returns an instance of this class
|
||||||
:py:class:`~PIL.ExifTags.IFD` members (most notably ``Exif`` and
|
|
||||||
``GPSInfo``).
|
|
||||||
|
|
||||||
Both root Exif and child IFD objects support dict interface and can be
|
Information can be read and written, iterated over or deleted::
|
||||||
indexed by int values that are available as enum members of
|
|
||||||
:py:class:`~PIL.ExifTags.Base`, :py:class:`~PIL.ExifTags.GPS`, and
|
print(exif[274]) # 1
|
||||||
:py:class:`~PIL.ExifTags.Interop`.
|
exif[274] = 2
|
||||||
|
for k, v in exif.items():
|
||||||
|
print("Tag", k, "Value", v) # Tag 274 Value 2
|
||||||
|
del exif[274]
|
||||||
|
|
||||||
|
To access information beyond IFD0, :py:meth:`~PIL.Image.Exif.get_ifd`
|
||||||
|
returns a dictionary::
|
||||||
|
|
||||||
|
from PIL import ExifTags
|
||||||
|
im = Image.open("exif_gps.jpg")
|
||||||
|
exif = im.getexif()
|
||||||
|
gps_ifd = exif.get_ifd(ExifTags.IFD.GPSInfo)
|
||||||
|
print(gps_ifd)
|
||||||
|
|
||||||
|
Other IFDs include ``ExifTags.IFD.Exif``, ``ExifTags.IFD.Makernote``,
|
||||||
|
``ExifTags.IFD.Interop`` and ``ExifTags.IFD.IFD1``.
|
||||||
|
|
||||||
|
:py:mod:`~PIL.ExifTags` also has enum classes to provide names for data::
|
||||||
|
|
||||||
|
print(exif[ExifTags.Base.Software]) # PIL
|
||||||
|
print(gps_ifd[ExifTags.GPS.GPSDateStamp]) # '1999:99:99 99:99:99'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
endian = None
|
endian = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user