Skip to content

Commit

Permalink
Don't upscale if the image is smaller than the size
Browse files Browse the repository at this point in the history
  • Loading branch information
orlnub123 authored and radarhere committed Feb 16, 2020
1 parent 137dc78 commit 5ca5352
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2236,18 +2236,18 @@ def thumbnail(self, size, resample=BICUBIC, reducing_gap=2.0):
: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)
else:
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))
Expand Down

0 comments on commit 5ca5352

Please sign in to comment.