Read EXIF data from subsequent MPO images

This commit is contained in:
Andrew Murray 2019-03-28 08:32:33 +11:00
parent 0306b80ef7
commit e00628af3b

View File

@ -18,7 +18,8 @@
# See the README file for information on usage and redistribution.
#
from . import Image, JpegImagePlugin
from . import Image, ImageFile, JpegImagePlugin
from ._binary import i16be as i16
# __version__ is deprecated and will be removed in a future version. Use
# PIL.__version__ instead.
@ -78,6 +79,16 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile):
return
self.fp = self.__fp
self.offset = self.__mpoffsets[frame]
self.fp.seek(self.offset + 2) # skip SOI marker
if "parsed_exif" in self.info:
del self.info["parsed_exif"]
if i16(self.fp.read(2)) == 0xFFE1: # APP1
n = i16(self.fp.read(2))-2
self.info["exif"] = ImageFile._safe_read(self.fp, n)
elif "exif" in self.info:
del self.info["exif"]
self.tile = [
("jpeg", (0, 0) + self.size, self.offset, (self.mode, ""))
]