mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-05-03 23:00:09 +08:00
Update nodes.py
This commit is contained in:
parent
e1391ddf9f
commit
b9c12ff13f
10
nodes.py
10
nodes.py
@ -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()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user