mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Change size of MPO image to match frame
This commit is contained in:
parent
e00628af3b
commit
a5b62857b0
BIN
Tests/images/sugarshack_frame_size.mpo
Normal file
BIN
Tests/images/sugarshack_frame_size.mpo
Normal file
Binary file not shown.
After Width: | Height: | Size: 117 KiB |
|
@ -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)
|
||||
|
|
|
@ -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"]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user