This commit is contained in:
thodnev 2017-04-19 19:44:14 +00:00 committed by GitHub
commit 575b1a51f4

View File

@ -1926,18 +1926,14 @@ class Image(object):
:returns: None
"""
# preserve aspect ratio
x, y = self.size
if x > size[0]:
y = int(max(y * size[0] / x, 1))
x = int(size[0])
if y > size[1]:
x = int(max(x * size[1] / y, 1))
y = int(size[1])
size = x, y
if size == self.size:
return
# preserve aspect ratio
x, y = self.size
if x > size[0] or y > size[1]:
factor = min(float(size[0])/x, float(size[1])/y)
x, y = int(x*factor), int(y*factor)
size = x, y
self.draft(None, size)