Updates to MPO handler based on review.

Took out the explicit reference to the MPO Plug-in in Image as it’s now
indirectly referenced via the JPEG Plug-in. Removed the direct MPO
Plug-in registration as it’s now shared with the JPEG Plug-in.
Commented on assertion.
This commit is contained in:
Eric W. Brown 2014-07-28 11:14:38 -04:00
parent 310bf90222
commit c97d1a5601
2 changed files with 5 additions and 5 deletions

View File

@ -353,10 +353,6 @@ def preinit():
from PIL import JpegImagePlugin
except ImportError:
pass
try:
from PIL import MpoImagePlugin
except ImportError:
pass
try:
from PIL import PpmImagePlugin
except ImportError:

View File

@ -44,6 +44,8 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile):
self.__mpoffsets = [mpent['DataOffset'] + self.info['mpoffset'] \
for mpent in self.mpinfo[0xB002]]
self.__mpoffsets[0] = 0
# Note that the following assertion will only be invalid if something
# gets broken within JpegImagePlugin.
assert self.__framecount == len(self.__mpoffsets)
del self.info['mpoffset'] # no longer needed
self.__fp = self.fp # FIXME: hack
@ -74,7 +76,9 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile):
# -------------------------------------------------------------------q-
# Registry stuff
Image.register_open("MPO", JpegImagePlugin.jpeg_factory, _accept)
# Note that since MPO shares a factory with JPEG, we do not need to do a
# separate registration for it here.
#Image.register_open("MPO", JpegImagePlugin.jpeg_factory, _accept)
Image.register_save("MPO", _save)
Image.register_extension("MPO", ".mpo")