Update nodes.py

This commit is contained in:
Kijai 2024-01-18 15:54:25 +02:00
parent e1391ddf9f
commit b9c12ff13f

View File

@ -1237,12 +1237,10 @@ class SaveImageWithAlpha:
a = 255. * alpha.cpu().numpy() a = 255. * alpha.cpu().numpy()
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8)) 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 # Resize the mask to match the image size
print("Applying mask") a_resized = Image.fromarray(a).resize(img.size, Image.ANTIALIAS)
a = np.clip(a, 0, 255).astype(np.uint8) a_resized = np.clip(a_resized, 0, 255).astype(np.uint8)
img.putalpha(Image.fromarray(a, mode='L')) img.putalpha(Image.fromarray(a_resized, mode='L'))
else:
raise ValueError("SaveImageWithAlpha: Mask size does not match")
metadata = None metadata = None
if not args.disable_metadata: if not args.disable_metadata:
metadata = PngInfo() metadata = PngInfo()