mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-06 21:03:18 +03:00
Merge pull request #6930 from greatvovan/patch-1
This commit is contained in:
commit
f2a2794834
|
@ -1432,6 +1432,11 @@ class Image:
|
||||||
return {get_name(root.tag): get_value(root)}
|
return {get_name(root.tag): get_value(root)}
|
||||||
|
|
||||||
def getexif(self):
|
def getexif(self):
|
||||||
|
"""
|
||||||
|
Gets EXIF data from the image.
|
||||||
|
|
||||||
|
:returns: an :py:class:`~PIL.Image.Exif` object.
|
||||||
|
"""
|
||||||
if self._exif is None:
|
if self._exif is None:
|
||||||
self._exif = Exif()
|
self._exif = Exif()
|
||||||
self._exif._loaded = False
|
self._exif._loaded = False
|
||||||
|
@ -3601,6 +3606,39 @@ atexit.register(core.clear_cache)
|
||||||
|
|
||||||
|
|
||||||
class Exif(MutableMapping):
|
class Exif(MutableMapping):
|
||||||
|
"""
|
||||||
|
This class provides read and write access to EXIF image data::
|
||||||
|
|
||||||
|
from PIL import Image
|
||||||
|
im = Image.open("exif.png")
|
||||||
|
exif = im.getexif() # Returns an instance of this class
|
||||||
|
|
||||||
|
Information can be read and written, iterated over or deleted::
|
||||||
|
|
||||||
|
print(exif[274]) # 1
|
||||||
|
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
|
||||||
bigtiff = False
|
bigtiff = False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user