From e226e4ed64f7bf9da69a82568683890f9654b603 Mon Sep 17 00:00:00 2001 From: orlnub123 Date: Tue, 4 Feb 2020 20:58:54 +0000 Subject: [PATCH] Don't upscale if the image is smaller than the size --- src/PIL/Image.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index e1ae4a678..0e9c4722b 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -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))