Corrected offset for MPO frames.

This commit is contained in:
Eric W. Brown 2014-07-22 18:23:45 -04:00
parent d5909e4946
commit 1d3fe7ff45
2 changed files with 3 additions and 5 deletions

View File

@ -115,7 +115,8 @@ def APP(self, marker):
elif marker == 0xFFE2 and s[:4] == b"MPF\0":
# extract MPO information
self.info["mp"] = s[4:]
self.info["mpoffset"] = self.fp.tell()
# offset is current location minus buffer size plus constant header size
self.info["mpoffset"] = self.fp.tell() - n + 4
def COM(self, marker):

View File

@ -42,6 +42,7 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile):
self.__framecount = self.mpinfo[0xB001]
self.__mpoffsets = [mpent['DataOffset'] + self.info['mpoffset'] \
for mpent in self.mpinfo[0xB002]]
self.__mpoffsets[0] = 0
assert self.__framecount == len(self.__mpoffsets)
del self.info['mpoffset'] # no longer needed
self.__fp = self.fp # FIXME: hack
@ -56,10 +57,6 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile):
self.fp = self.__fp
self.fp.seek(self.__mpoffsets[frame])
self.offset = self.__mpoffsets[frame]
rawmode = self.mode
if self.mode == "CMYK":
rawmode = "CMYK;I" # assume adobe conventions
self.tile = [("jpeg", (0, 0) + self.size, 0, (rawmode, ""))]
self.__frame = frame
def tell(self):