Merge pull request #11748 from huaizong/fix/x/resize-less-than-two-pixel-error
fix: check fill size none zero when resize (fixes #11425)
This commit is contained in:
commit
e93f582a78
@ -306,10 +306,12 @@ def resize_image(resize_mode, im, width, height, upscaler_name=None):
|
|||||||
|
|
||||||
if ratio < src_ratio:
|
if ratio < src_ratio:
|
||||||
fill_height = height // 2 - src_h // 2
|
fill_height = height // 2 - src_h // 2
|
||||||
|
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, 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))
|
res.paste(resized.resize((width, fill_height), box=(0, resized.height, width, resized.height)), box=(0, fill_height + src_h))
|
||||||
elif ratio > src_ratio:
|
elif ratio > src_ratio:
|
||||||
fill_width = width // 2 - src_w // 2
|
fill_width = width // 2 - src_w // 2
|
||||||
|
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=(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))
|
res.paste(resized.resize((fill_width, height), box=(resized.width, 0, resized.width, height)), box=(fill_width + src_w, 0))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user