From 71cd8941fefd316070e91dee41eb5382bb35efee Mon Sep 17 00:00:00 2001 From: fujammy <467918@qq.com> Date: Sun, 5 Jan 2025 01:20:58 +0800 Subject: [PATCH] Enhance ImageResolutionAdjuster to support feathering in mask calculations. Updated mask creation logic in both 'contain' and 'pad' modes to utilize the new feathering parameter, improving the quality of image processing. This change enhances flexibility and visual output for users adjusting image resolutions. --- modules/images/image_resolution_adjuster.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/images/image_resolution_adjuster.py b/modules/images/image_resolution_adjuster.py index 5b0d7ca..ab6bab6 100644 --- a/modules/images/image_resolution_adjuster.py +++ b/modules/images/image_resolution_adjuster.py @@ -425,10 +425,14 @@ class ImageResolutionAdjuster: for image in images: if extend_mode in ["contain", "cover", "fill", "inside", "outside"]: scaled_image, mask, width, height = resize_image(image, target_width, target_height, method=extend_mode, background_color=background_color) + # 更新mask以使用feathering参数 + mask = calculate_mask((image.shape[1], image.shape[0]), (width, height), extend_mode, feather=feathering, scale_factor=scale_factor) elif extend_mode in ["top", "bottom", "left", "right", "center"]: scaled_image, mask, width, height = pad_image(image, target_width, target_height, position=extend_mode, background_color=background_color) + # 更新mask以使用feathering参数 + mask = calculate_mask((image.shape[1], image.shape[0]), (width, height), extend_mode, feather=feathering, scale_factor=scale_factor) else: raise ValueError(f"Invalid extend_mode: {extend_mode}")