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:
Glandos 2019-03-06 22:01:42 +01:00
parent 30879dfb34
commit 5d8b14fc9e

View File

@ -455,6 +455,12 @@ def _getexif(self):
# and is likely to be replaced with something better in a future
# 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
# application marker (!).
try:
@ -493,6 +499,8 @@ def _getexif(self):
info.load(fp)
exif[0x8825] = _fixup_dict(info)
# Cache the result for future use
self.info["parsed_exif"] = exif
return exif