BadCafeCode / masquerade-nodes-comfyui

A powerful set of mask-related nodes for ComfyUI
MIT License
348 stars 34 forks source link

Cut by mask crop to the mask borders #18

Open GXcells opened 9 months ago

GXcells commented 9 months ago

Hi, when I use cut by mask, it gives an images which is cropped to the limit of the mask. So at the end, the resulting image does not have anymore the original size because my "white" part of the mask does not touch the borders of the original image size.

Is there a way to cut image by a mask but keeping the original size? (using the force resize does not work because it distorts the image, and does not add back the pixels missing.

GXcells commented 9 months ago

Ok found a solution by using "paste by mask "and using an empty image of the same size as the original as "image_base", then using the cut by mask output as "image_to_paste", and the mask as "mask". But the problem is that the removed part of the image due to masking are now black and not transparent. Any solution? EDIT: Ok solved the non transparent background by modifying the empty image node to create a RGBA image with "0" in channel a instead of a RGB image.

As a separate point, I don't understand the behavior of "paste by mask". How can this node understand how to paste at the right place whereas the image output from cut by mask is a different size than the original image?

Also if I only use "paste by mask" without using the output of "cut by mask", the resulting image is not properly aligned.