Change size of MPO image to match frame

This commit is contained in:
Andrew Murray 2019-01-18 16:08:46 +11:00
parent e00628af3b
commit a5b62857b0
3 changed files with 13 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

View File

@ -55,6 +55,15 @@ class TestFileMpo(PillowTestCase):
self.assertEqual(info[296], 2)
self.assertEqual(info[34665], 188)
def test_frame_size(self):
# This image has been hexedited to contain a different size
# in the EXIF data of the second frame
im = Image.open("Tests/images/sugarshack_frame_size.mpo")
self.assertEqual(im.size, (640, 480))
im.seek(1)
self.assertEqual(im.size, (680, 480))
def test_mp(self):
for test_file in test_files:
im = Image.open(test_file)

View File

@ -86,6 +86,10 @@ class MpoImageFile(JpegImagePlugin.JpegImageFile):
if i16(self.fp.read(2)) == 0xFFE1: # APP1
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])
elif "exif" in self.info:
del self.info["exif"]