mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
d50445ff30
Similar to the recent adoption of Black. isort is a Python utility to sort imports alphabetically and automatically separate into sections. By using isort, contributors can quickly and automatically conform to the projects style without thinking. Just let the tool do it. Uses the configuration recommended by the Black to avoid conflicts of style. Rewrite TestImageQt.test_deprecated to no rely on import order.
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
from PIL import Image
|
|
|
|
from .helper import PillowTestCase, hopper
|
|
|
|
|
|
class TestImageThumbnail(PillowTestCase):
|
|
def test_sanity(self):
|
|
|
|
im = hopper()
|
|
im.thumbnail((100, 100))
|
|
|
|
self.assert_image(im, im.mode, (100, 100))
|
|
|
|
def test_aspect(self):
|
|
|
|
im = hopper()
|
|
im.thumbnail((100, 100))
|
|
self.assert_image(im, im.mode, (100, 100))
|
|
|
|
im = hopper().resize((128, 256))
|
|
im.thumbnail((100, 100))
|
|
self.assert_image(im, im.mode, (50, 100))
|
|
|
|
im = hopper().resize((128, 256))
|
|
im.thumbnail((50, 100))
|
|
self.assert_image(im, im.mode, (50, 100))
|
|
|
|
im = hopper().resize((256, 128))
|
|
im.thumbnail((100, 100))
|
|
self.assert_image(im, im.mode, (100, 50))
|
|
|
|
im = hopper().resize((256, 128))
|
|
im.thumbnail((100, 50))
|
|
self.assert_image(im, im.mode, (100, 50))
|
|
|
|
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))
|