mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-01 02:13:11 +03:00
protect .draft() from second call
This commit is contained in:
parent
8f6b7b258b
commit
55fca4857c
|
@ -341,6 +341,10 @@ class JpegImageFile(ImageFile.ImageFile):
|
||||||
if len(self.tile) != 1:
|
if len(self.tile) != 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Protect from second call
|
||||||
|
if self.decoderconfig:
|
||||||
|
return
|
||||||
|
|
||||||
d, e, o, a = self.tile[0]
|
d, e, o, a = self.tile[0]
|
||||||
scale = 0
|
scale = 0
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,9 @@ class TestImageDraft(PillowTestCase):
|
||||||
for in_size, req_size, out_size in [
|
for in_size, req_size, out_size in [
|
||||||
((435, 361), (2048, 2048), (435, 361)), # bigger
|
((435, 361), (2048, 2048), (435, 361)), # bigger
|
||||||
((435, 361), (435, 361), (435, 361)), # same
|
((435, 361), (435, 361), (435, 361)), # same
|
||||||
|
((128, 128), (64, 64), (64, 64)),
|
||||||
|
((128, 128), (32, 32), (32, 32)),
|
||||||
|
((128, 128), (16, 16), (16, 16)),
|
||||||
|
|
||||||
# large requested width
|
# large requested width
|
||||||
((435, 361), (218, 128), (435, 361)), # almost 2x
|
((435, 361), (218, 128), (435, 361)), # almost 2x
|
||||||
|
@ -40,6 +43,7 @@ class TestImageDraft(PillowTestCase):
|
||||||
((435, 361), (16, 22), (55, 46)), # more than 16x
|
((435, 361), (16, 22), (55, 46)), # more than 16x
|
||||||
]:
|
]:
|
||||||
im = self.draft_roundtrip('L', in_size, None, req_size)
|
im = self.draft_roundtrip('L', in_size, None, req_size)
|
||||||
|
im.load()
|
||||||
self.assertEqual(im.size, out_size)
|
self.assertEqual(im.size, out_size)
|
||||||
|
|
||||||
def test_mode(self):
|
def test_mode(self):
|
||||||
|
@ -58,8 +62,13 @@ class TestImageDraft(PillowTestCase):
|
||||||
("CMYK", "YCbCr", "CMYK"),
|
("CMYK", "YCbCr", "CMYK"),
|
||||||
]:
|
]:
|
||||||
im = self.draft_roundtrip(in_mode, (64, 64), req_mode, None)
|
im = self.draft_roundtrip(in_mode, (64, 64), req_mode, None)
|
||||||
|
im.load()
|
||||||
self.assertEqual(im.mode, out_mode)
|
self.assertEqual(im.mode, out_mode)
|
||||||
|
|
||||||
|
def test_several_drafts(self):
|
||||||
|
im = self.draft_roundtrip('L', (128, 128), None, (64, 64))
|
||||||
|
im.draft(None, (64, 64))
|
||||||
|
im.load()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user