@@ -1433,7 +1433,7 @@ def get_value(element):
1433
1433
1434
1434
def getexif (self ):
1435
1435
"""
1436
- Gets EXIF data of the image.
1436
+ Gets EXIF data from the image.
1437
1437
1438
1438
:returns: an :py:class:`~PIL.Image.Exif` object.
1439
1439
"""
@@ -3607,18 +3607,36 @@ def _apply_env_variables(env=None):
3607
3607
3608
3608
class Exif (MutableMapping ):
3609
3609
"""
3610
- Exif class provides read and write access to EXIF image data.
3610
+ This class provides read and write access to EXIF image data::
3611
3611
3612
- Only basic information is available on the root level, in Exif object
3613
- itself. In order to access the rest, obtain their respective IFDs using
3614
- :py:meth:`~PIL.Image.Exif.get_ifd` method and one of
3615
- :py:class:`~PIL.ExifTags.IFD` members (most notably ``Exif`` and
3616
- ``GPSInfo``).
3612
+ from PIL import Image
3613
+ im = Image.open("exif.png")
3614
+ exif = im.getexif() # Returns an instance of this class
3615
+
3616
+ Information can be read and written, iterated over or deleted::
3617
+
3618
+ print(exif[274]) # 1
3619
+ exif[274] = 2
3620
+ for k, v in exif.items():
3621
+ print("Tag", k, "Value", v) # Tag 274 Value 2
3622
+ del exif[274]
3623
+
3624
+ To access information beyond IFD0, :py:meth:`~PIL.Image.Exif.get_ifd`
3625
+ returns a dictionary::
3626
+
3627
+ from PIL import ExifTags
3628
+ im = Image.open("exif_gps.jpg")
3629
+ exif = im.getexif()
3630
+ gps_ifd = exif.get_ifd(ExifTags.IFD.GPSInfo)
3631
+ print(gps_ifd)
3632
+
3633
+ Other IFDs include ``ExifTags.IFD.Exif``, ``ExifTags.IFD.Makernote``,
3634
+ ``ExifTags.IFD.Interop`` and ``ExifTags.IFD.IFD1``.
3635
+
3636
+ :py:mod:`~PIL.ExifTags` also has enum classes to provide names for data::
3617
3637
3618
- Both root Exif and child IFD objects support dict interface and can be
3619
- indexed by int values that are available as enum members of
3620
- :py:class:`~PIL.ExifTags.Base`, :py:class:`~PIL.ExifTags.GPS`, and
3621
- :py:class:`~PIL.ExifTags.Interop`.
3638
+ print(exif[ExifTags.Base.Software]) # PIL
3639
+ print(gps_ifd[ExifTags.GPS.GPSDateStamp]) # '1999:99:99 99:99:99'
3622
3640
"""
3623
3641
3624
3642
endian = None
0 commit comments