mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 10:46:16 +03:00
use a box from draft in thumbnail
This commit is contained in:
parent
4126f6cdf7
commit
375556ffb5
|
@ -1,6 +1,6 @@
|
|||
from PIL import Image
|
||||
|
||||
from .helper import PillowTestCase, hopper
|
||||
from .helper import PillowTestCase, hopper, fromstring, tostring
|
||||
|
||||
|
||||
class TestImageThumbnail(PillowTestCase):
|
||||
|
@ -47,3 +47,14 @@ class TestImageThumbnail(PillowTestCase):
|
|||
im = Image.open("Tests/images/hopper.jpg")
|
||||
im.thumbnail((64, 64))
|
||||
self.assert_image(im, im.mode, (64, 64))
|
||||
|
||||
def test_DCT_scaling_edges(self):
|
||||
# Make an image with red borders with size (N * 8) + 1 to cross DCT grid
|
||||
im = Image.new('RGB', (97, 97), 'red')
|
||||
im.paste(Image.new('RGB', (95, 95)), (1, 1))
|
||||
|
||||
thumb = fromstring(tostring(im, "JPEG", quality=95))
|
||||
thumb.thumbnail((24, 24), Image.BICUBIC)
|
||||
|
||||
ref = im.resize((24, 24), Image.BICUBIC)
|
||||
self.assert_image_similar(thumb, ref, 2)
|
||||
|
|
|
@ -2212,14 +2212,17 @@ class Image(object):
|
|||
x = int(max(x * size[1] / y, 1))
|
||||
y = int(size[1])
|
||||
size = x, y
|
||||
box = None
|
||||
|
||||
if size == self.size:
|
||||
return
|
||||
|
||||
self.draft(None, size)
|
||||
res = self.draft(None, size)
|
||||
if res is not None:
|
||||
box = res[1]
|
||||
|
||||
if self.size != size:
|
||||
im = self.resize(size, resample)
|
||||
im = self.resize(size, resample, box=box)
|
||||
|
||||
self.im = im.im
|
||||
self._size = size
|
||||
|
|
Loading…
Reference in New Issue
Block a user