Don't upscale if the image is smaller than the size

This commit is contained in:
orlnub123 2020-02-04 20:58:54 +00:00 committed by Andrew Murray
parent e9ef1d236d
commit e226e4ed64

View File

@ -2236,8 +2236,11 @@ class Image:
:returns: None
"""
# preserve aspect ratio
x, y = size
if x >= self.width and y >= self.height:
return
# preserve aspect ratio
aspect = self.width / self.height
if x / y >= aspect:
x = max(y * aspect, 1)
@ -2245,9 +2248,6 @@ class Image:
y = max(x / aspect, 1)
size = (round(x), round(y))
if size == self.size:
return
box = None
if reducing_gap is not None:
res = self.draft(None, (size[0] * reducing_gap, size[1] * reducing_gap))