Commit 6c0d5d11 authored by 王怀宗's avatar 王怀宗
Browse files

fix: check fill size none zero when resize (fixes #11425)

parent f865d3e1
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -302,10 +302,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))