mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-04 21:50:54 +03:00
Cache EXIF information
In case we need to call _getexif from the outside, since it's already called while parsing. cache the result in self.info. This is compatible with other file using _getexif, like WebP.
This commit is contained in:
parent
30879dfb34
commit
5d8b14fc9e
|
@ -455,6 +455,12 @@ def _getexif(self):
|
||||||
# and is likely to be replaced with something better in a future
|
# and is likely to be replaced with something better in a future
|
||||||
# version.
|
# version.
|
||||||
|
|
||||||
|
# Use the cached version if possible
|
||||||
|
try:
|
||||||
|
return self.info["parsed_exif"]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
# The EXIF record consists of a TIFF file embedded in a JPEG
|
# The EXIF record consists of a TIFF file embedded in a JPEG
|
||||||
# application marker (!).
|
# application marker (!).
|
||||||
try:
|
try:
|
||||||
|
@ -493,6 +499,8 @@ def _getexif(self):
|
||||||
info.load(fp)
|
info.load(fp)
|
||||||
exif[0x8825] = _fixup_dict(info)
|
exif[0x8825] = _fixup_dict(info)
|
||||||
|
|
||||||
|
# Cache the result for future use
|
||||||
|
self.info["parsed_exif"] = exif
|
||||||
return exif
|
return exif
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user