Merge pull request #5168 from radarhere/mpo

This commit is contained in:
Hugo van Kemenade 2021-03-07 11:38:36 +02:00 committed by GitHub
commit 95986f38da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 117 KiB

View File

@ -89,6 +89,20 @@ def test_frame_size():
assert im.size == (680, 480)
def test_ignore_frame_size():
# Ignore the different size of the second frame
# since this is not a "Large Thumbnail" image
with Image.open("Tests/images/ignore_frame_size.mpo") as im:
assert im.size == (64, 64)
im.seek(1)
assert (
im.mpinfo[0xB002][1]["Attribute"]["MPType"]
== "Multi-Frame Image: (Disparity)"
)
assert im.size == (64, 64)
def test_parallax():
# Nintendo
with Image.open("Tests/images/sugarshack.mpo") as im:
@ -132,7 +146,7 @@ def test_mp_attribute():
with Image.open(test_file) as im:
mpinfo = im._getmp()
frameNumber = 0
for mpentry in mpinfo[45058]:
for mpentry in mpinfo[0xB002]:
mpattr = mpentry["Attribute"]
if frameNumber:
assert not mpattr["RepresentativeImageFlag"]

View File

@ -82,9 +82,11 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile):
n = i16(self.fp.read(2)) - 2
self.info["exif"] = ImageFile._safe_read(self.fp, n)
exif = self.getexif()
if 40962 in exif and 40963 in exif:
self._size = (exif[40962], exif[40963])
mptype = self.mpinfo[0xB002][frame]["Attribute"]["MPType"]
if mptype.startswith("Large Thumbnail"):
exif = self.getexif()
if 40962 in exif and 40963 in exif:
self._size = (exif[40962], exif[40963])
elif "exif" in self.info:
del self.info["exif"]