From e7892ad966c17659add47a3857449ac169fb9fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=81=B0=E7=99=BD=E5=BD=B1=E7=89=87?= <812584691@qq.com> Date: Tue, 20 Jan 2026 17:44:37 +0800 Subject: [PATCH] Fix: ensure resize dimensions are at least 1 to prevent PIL error --- imgutils/operate/censor_.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/imgutils/operate/censor_.py b/imgutils/operate/censor_.py index 0dfd5735a20..683c68c56f8 100644 --- a/imgutils/operate/censor_.py +++ b/imgutils/operate/censor_.py @@ -93,7 +93,9 @@ def censor_area(self, image: Image.Image, area: Tuple[int, int, int, int], radiu x0, y0, x1, y1 = area width, height = x1 - x0, y1 - y0 censor_area = image.crop((x0, y0, x1, y1)) - censor_area = censor_area.resize((width // radius, height // radius)).resize((width, height), Image.NEAREST) + target_w = max(1, width // radius) + target_h = max(1, height // radius) + censor_area = censor_area.resize((target_w, target_h)).resize((width, height), Image.NEAREST) image.paste(censor_area, (x0, y0, x1, y1)) return image