Merge pull request #3042 from hugovk/3006-parser-feed

Fix TypeError for JPEG2000 parser feed
This commit is contained in:
wiredfool 2018-03-21 07:56:23 +00:00 committed by GitHub
commit 0e9f07def9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -176,6 +176,19 @@ class TestFileJpeg2k(PillowTestCase):
with self.assertRaises(IOError):
Image.open('Tests/images/unbound_variable.jp2')
def test_parser_feed(self):
# Arrange
from PIL import ImageFile
with open('Tests/images/test-card-lossless.jp2', 'rb') as f:
data = f.read()
# Act
p = ImageFile.Parser()
p.feed(data)
# Assert
self.assertEqual(p.image.size, (640, 480))
if __name__ == '__main__':
unittest.main()

View File

@ -192,7 +192,7 @@ class Jpeg2KImageFile(ImageFile.ImageFile):
length = -1
self.tile = [('jpeg2k', (0, 0) + self.size, 0,
(self.codec, self.reduce, self.layers, fd, length, self.fp))]
(self.codec, self.reduce, self.layers, fd, length))]
def load(self):
if self.reduce: