ComfyUI Node
Remove BG by Mask
Cut out a subject using a mask: keep the pixels inside the mask and make everything else transparent. Optionally fill enclosed holes, crop to the subject bounding box with an adjustable margin, and add an outline. Returns an RGBA image, an RGB image composited over the stroke colour, and the mask actually used. A batch shares one crop box so every frame has the same size.
Remove BG by Mask
- image
- mask
- rgba
- rgb
- mask
◄fill_holestrue►
◄crop_to_masktrue►
◄crop_factor1.2►
◄stroke_width0►
◄stroke_color#364254►
CategoryQG-tools/Mask
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Source image; all frames in a batch share one crop box so the output stays stackable. | |
| mask | MASK | Mask: values above 127 are kept, the rest is cut away. Resized to the image if sizes differ; the last mask is reused when the batch has fewer masks than images. | |
| fill_holes | BOOLEAN | true | Fill enclosed holes surrounded by foreground (e.g. a ring made by an arm). Only interior gaps are filled; the outside background is untouched. |
| crop_to_mask | BOOLEAN | true | Crop the empty border using the foreground bounding box, keeping just the subject area. Turn off to keep the original canvas. |
| crop_factor | FLOAT | 1.21–2 | How far to expand the crop box. 1.0 hugs the subject, 1.2 leaves some margin; larger values leave more empty space. |
| stroke_width | INT | 00–512 | Width in pixels of the outline drawn outside the foreground edge; 0 disables it. |
| stroke_color | STRING | #364254 | Outline colour, also used as the backdrop of the RGB output. Accepts #RRGGBB / #RGB / RRGGBB; invalid values fall back to the default instead of erroring. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| rgba | IMAGE | RGBA cutout with a transparent background. |
| rgb | IMAGE | Opaque RGB version: transparent areas are filled with the stroke colour. |
| mask | MASK | The single-channel mask after hole filling and cropping. |