mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Merge pull request #3632 from radarhere/thumbnail
Do not resize in Image.thumbnail if already the destination size
This commit is contained in:
commit
d9f5f44799
|
@ -1,4 +1,5 @@
|
|||
from .helper import PillowTestCase, hopper
|
||||
from PIL import Image
|
||||
|
||||
|
||||
class TestImageThumbnail(PillowTestCase):
|
||||
|
@ -35,3 +36,14 @@ class TestImageThumbnail(PillowTestCase):
|
|||
im = hopper().resize((128, 128))
|
||||
im.thumbnail((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))
|
||||
|
|
|
@ -2128,11 +2128,12 @@ class Image(object):
|
|||
|
||||
self.draft(None, size)
|
||||
|
||||
im = self.resize(size, resample)
|
||||
if self.size != size:
|
||||
im = self.resize(size, resample)
|
||||
|
||||
self.im = im.im
|
||||
self.mode = im.mode
|
||||
self._size = size
|
||||
self.im = im.im
|
||||
self._size = size
|
||||
self.mode = self.im.mode
|
||||
|
||||
self.readonly = 0
|
||||
self.pyaccess = None
|
||||
|
|
Loading…
Reference in New Issue
Block a user