mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-05 14:10:52 +03:00
Don't upscale if the image is smaller than the size
This commit is contained in:
parent
e9ef1d236d
commit
e226e4ed64
|
@ -2236,8 +2236,11 @@ class Image:
|
||||||
:returns: None
|
:returns: None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# preserve aspect ratio
|
|
||||||
x, y = size
|
x, y = size
|
||||||
|
if x >= self.width and y >= self.height:
|
||||||
|
return
|
||||||
|
|
||||||
|
# preserve aspect ratio
|
||||||
aspect = self.width / self.height
|
aspect = self.width / self.height
|
||||||
if x / y >= aspect:
|
if x / y >= aspect:
|
||||||
x = max(y * aspect, 1)
|
x = max(y * aspect, 1)
|
||||||
|
@ -2245,9 +2248,6 @@ class Image:
|
||||||
y = max(x / aspect, 1)
|
y = max(x / aspect, 1)
|
||||||
size = (round(x), round(y))
|
size = (round(x), round(y))
|
||||||
|
|
||||||
if size == self.size:
|
|
||||||
return
|
|
||||||
|
|
||||||
box = None
|
box = None
|
||||||
if reducing_gap is not None:
|
if reducing_gap is not None:
|
||||||
res = self.draft(None, (size[0] * reducing_gap, size[1] * reducing_gap))
|
res = self.draft(None, (size[0] * reducing_gap, size[1] * reducing_gap))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user