diff --git a/PIL/JpegImagePlugin.py b/PIL/JpegImagePlugin.py index ce225ddc1..bedc42373 100644 --- a/PIL/JpegImagePlugin.py +++ b/PIL/JpegImagePlugin.py @@ -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): diff --git a/PIL/MpoImagePlugin.py b/PIL/MpoImagePlugin.py index 6accf5110..6594b74b0 100644 --- a/PIL/MpoImagePlugin.py +++ b/PIL/MpoImagePlugin.py @@ -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):