From b9c12ff13fd8435caef2cfe609e4e897c416b686 Mon Sep 17 00:00:00 2001 From: Kijai <40791699+kijai@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:54:25 +0200 Subject: [PATCH] Update nodes.py --- nodes.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nodes.py b/nodes.py index 2553d58..9859405 100644 --- a/nodes.py +++ b/nodes.py @@ -1237,12 +1237,10 @@ class SaveImageWithAlpha: a = 255. * alpha.cpu().numpy() img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8)) - if a.shape == img.size[::-1]: # Check if the mask has the same size as the image - print("Applying mask") - a = np.clip(a, 0, 255).astype(np.uint8) - img.putalpha(Image.fromarray(a, mode='L')) - else: - raise ValueError("SaveImageWithAlpha: Mask size does not match") + # Resize the mask to match the image size + a_resized = Image.fromarray(a).resize(img.size, Image.ANTIALIAS) + a_resized = np.clip(a_resized, 0, 255).astype(np.uint8) + img.putalpha(Image.fromarray(a_resized, mode='L')) metadata = None if not args.disable_metadata: metadata = PngInfo()