aboutsummaryrefslogtreecommitdiff
path: root/modules/images.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-07-13 14:48:19 +0300
committerGitHub <noreply@github.com>2023-07-13 14:48:19 +0300
commite93f582a7886904639dc9164be87e040a0572c13 (patch)
tree6380c0be5c28e8ed2fc29d0f175d58d590fb1791 /modules/images.py
parente5ca9877781bf2ce45edfb9c46ba532668c50de9 (diff)
parent6c0d5d1198576dbe664f55cffec27b03d0789efd (diff)
Merge pull request #11748 from huaizong/fix/x/resize-less-than-two-pixel-error
fix: check fill size none zero when resize (fixes #11425)
Diffstat (limited to 'modules/images.py')
-rw-r--r--modules/images.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/modules/images.py b/modules/images.py
index b5412548..4bdedb7f 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -306,12 +306,14 @@ def resize_image(resize_mode, im, width, height, upscaler_name=None):
if ratio < src_ratio:
fill_height = height // 2 - src_h // 2
- res.paste(resized.resize((width, fill_height), box=(0, 0, width, 0)), box=(0, 0))
- res.paste(resized.resize((width, fill_height), box=(0, resized.height, width, resized.height)), box=(0, fill_height + src_h))
+ if fill_height > 0:
+ res.paste(resized.resize((width, fill_height), box=(0, 0, width, 0)), box=(0, 0))
+ res.paste(resized.resize((width, fill_height), box=(0, resized.height, width, resized.height)), box=(0, fill_height + src_h))
elif ratio > src_ratio:
fill_width = width // 2 - src_w // 2
- res.paste(resized.resize((fill_width, height), box=(0, 0, 0, height)), box=(0, 0))
- res.paste(resized.resize((fill_width, height), box=(resized.width, 0, resized.width, height)), box=(fill_width + src_w, 0))
+ if fill_width > 0:
+ res.paste(resized.resize((fill_width, height), box=(0, 0, 0, height)), box=(0, 0))
+ res.paste(resized.resize((fill_width, height), box=(resized.width, 0, resized.width, height)), box=(fill_width + src_w, 0))
return res