Add truncated jpeg tests

This commit is contained in:
Konstantin Kopachev 2018-03-07 21:31:51 -08:00
parent 1e9e64c8b0
commit 5269bbc268
No known key found for this signature in database
GPG Key ID: CECF757E656F4F62
2 changed files with 16 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -348,6 +348,22 @@ class TestFileJpeg(PillowTestCase):
filename = "Tests/images/jpeg_ff00_header.jpg"
Image.open(filename)
def test_truncated_jpeg_should_read_all_the_data(self):
filename = "Tests/images/truncated_jpeg.jpg"
ImageFile.LOAD_TRUNCATED_IMAGES = True
im = Image.open(filename)
im.load()
ImageFile.LOAD_TRUNCATED_IMAGES = False
self.assertIsNotNone(im.getbbox())
def test_truncated_jpeg_throws_IOError(self):
filename = "Tests/images/truncated_jpeg.jpg"
im = Image.open(filename)
with self.assertRaises(IOError):
im.load()
def _n_qtables_helper(self, n, test_file):
im = Image.open(test_file)
f = self.tempfile('temp.jpg')