mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-09 06:44:45 +03:00
fix MPO parsing issue
This commit is contained in:
parent
e58a773c29
commit
dd1a6f1f13
|
@ -467,7 +467,7 @@ def _getmp(self):
|
||||||
try:
|
try:
|
||||||
quant = mp[0xB001]
|
quant = mp[0xB001]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise SyntaxError("malformed MP Index (no number of images)")
|
raise TypeError("malformed MP Index (no number of images)")
|
||||||
# get MP entries
|
# get MP entries
|
||||||
try:
|
try:
|
||||||
mpentries = []
|
mpentries = []
|
||||||
|
@ -491,7 +491,7 @@ def _getmp(self):
|
||||||
if mpentryattr['ImageDataFormat'] == 0:
|
if mpentryattr['ImageDataFormat'] == 0:
|
||||||
mpentryattr['ImageDataFormat'] = 'JPEG'
|
mpentryattr['ImageDataFormat'] = 'JPEG'
|
||||||
else:
|
else:
|
||||||
raise SyntaxError("unsupported picture format in MPO")
|
raise TypeError("unsupported picture format in MPO")
|
||||||
mptypemap = {
|
mptypemap = {
|
||||||
0x000000: 'Undefined',
|
0x000000: 'Undefined',
|
||||||
0x010001: 'Large Thumbnail (VGA Equivalent)',
|
0x010001: 'Large Thumbnail (VGA Equivalent)',
|
||||||
|
@ -507,7 +507,7 @@ def _getmp(self):
|
||||||
mpentries.append(mpentry)
|
mpentries.append(mpentry)
|
||||||
mp[0xB002] = mpentries
|
mp[0xB002] = mpentries
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise SyntaxError("malformed MP Index (bad MP Entry)")
|
raise TypeError("malformed MP Index (bad MP Entry)")
|
||||||
# Next we should try and parse the individual image unique ID list;
|
# Next we should try and parse the individual image unique ID list;
|
||||||
# we don't because I've never seen this actually used in a real MPO
|
# we don't because I've never seen this actually used in a real MPO
|
||||||
# file and so can't test it.
|
# file and so can't test it.
|
||||||
|
@ -713,8 +713,8 @@ def _save_cjpeg(im, fp, filename):
|
||||||
# Factory for making JPEG and MPO instances
|
# Factory for making JPEG and MPO instances
|
||||||
def jpeg_factory(fp=None, filename=None):
|
def jpeg_factory(fp=None, filename=None):
|
||||||
im = JpegImageFile(fp, filename)
|
im = JpegImageFile(fp, filename)
|
||||||
mpheader = im._getmp()
|
|
||||||
try:
|
try:
|
||||||
|
mpheader = im._getmp()
|
||||||
if mpheader[45057] > 1:
|
if mpheader[45057] > 1:
|
||||||
# It's actually an MPO
|
# It's actually an MPO
|
||||||
from .MpoImagePlugin import MpoImageFile
|
from .MpoImagePlugin import MpoImageFile
|
||||||
|
|
Loading…
Reference in New Issue
Block a user