mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 01:34:24 +03:00
Do not resize if already the destination size
This commit is contained in:
parent
a5919d9384
commit
1162b4cf83
|
@ -1,4 +1,5 @@
|
||||||
from .helper import PillowTestCase, hopper
|
from .helper import PillowTestCase, hopper
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
class TestImageThumbnail(PillowTestCase):
|
class TestImageThumbnail(PillowTestCase):
|
||||||
|
@ -35,3 +36,14 @@ class TestImageThumbnail(PillowTestCase):
|
||||||
im = hopper().resize((128, 128))
|
im = hopper().resize((128, 128))
|
||||||
im.thumbnail((100, 100))
|
im.thumbnail((100, 100))
|
||||||
self.assert_image(im, im.mode, (100, 100))
|
self.assert_image(im, im.mode, (100, 100))
|
||||||
|
|
||||||
|
def test_no_resize(self):
|
||||||
|
# Check that draft() can resize the image to the destination size
|
||||||
|
im = Image.open("Tests/images/hopper.jpg")
|
||||||
|
im.draft(None, (64, 64))
|
||||||
|
self.assertEqual(im.size, (64, 64))
|
||||||
|
|
||||||
|
# Test thumbnail(), where only draft() is necessary to resize the image
|
||||||
|
im = Image.open("Tests/images/hopper.jpg")
|
||||||
|
im.thumbnail((64, 64))
|
||||||
|
self.assert_image(im, im.mode, (64, 64))
|
||||||
|
|
|
@ -2129,11 +2129,12 @@ class Image(object):
|
||||||
|
|
||||||
self.draft(None, size)
|
self.draft(None, size)
|
||||||
|
|
||||||
|
if self.size != size:
|
||||||
im = self.resize(size, resample)
|
im = self.resize(size, resample)
|
||||||
|
|
||||||
self.im = im.im
|
self.im = im.im
|
||||||
self.mode = im.mode
|
|
||||||
self._size = size
|
self._size = size
|
||||||
|
self.mode = self.im.mode
|
||||||
|
|
||||||
self.readonly = 0
|
self.readonly = 0
|
||||||
self.pyaccess = None
|
self.pyaccess = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user