Image/Mask Converter (RMBG) 🖼️🎭
Swap between image and mask types
- image
- mask
- IMAGE
- MASK
ComfyUI is picky about types. A MASK is not an IMAGE, and a node that wants one will refuse the other, even though to your eyes they're both grayscale pictures of the same thing. This node is the little translator that converts between them, in both directions, so you stop hitting that wall.
It's unglamorous and you'll use it constantly. Half of ComfyUI graph-building is getting the right type into the right socket, and mask-vs-image is one of the most common mismatches - you've got a mask from a segmentation node and a downstream node that only speaks IMAGE, or vice versa. Drop this in the middle and the types line up.
How it works
Feed it an image and it gives you back a mask (derived from a channel you choose). Feed it a mask and it gives you back an image. Both inputs are optional, so you use it in whichever direction you need - connect the one you have, take the output you want.
The inputs and outputs that matter
image(optional) - connect this when you're converting an image to a mask.mask(optional) - connect this when you're converting a mask to an image.mask_channel(defaultalpha) - when going from image to mask, which channel becomes the mask:alpha,red,green, orblue. Alpha for transparent PNGs; a color channel when your mask was stored there.
Outputs are IMAGE and MASK - take whichever one you were converting toward.
How to install it
- ComfyUI Manager: search
Comfyui-RMBG, install, restart. - Manual:
cd ComfyUI/custom_nodes && git clone https://github.com/1038lab/ComfyUI-RMBG, thenpip install -r requirements.txt, and restart.
No model, pure conversion - instant.
Common issues
The one that catches people: converting an image to a mask on the wrong channel. If you leave mask_channel on alpha but your image has no alpha, you get an empty mask and wonder why the rest of the graph does nothing. Check which channel actually holds your mask data - for a plain grayscale mask baked into an image, any of the color channels works; for a transparent PNG, it's alpha. The other thing worth knowing is that this is a type conversion, not a fix-up: it won't clean or threshold anything, it just moves data between the IMAGE and MASK slots. If you need to actually process the mask - blur, offset, fill holes - that's the Mask Enhancer node, not this one.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| imageopt | IMAGE | — | |
| maskopt | MASK | — | |
| mask_channelopt | COMBO | alpha | 4 options: alpha, red, green, blue |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |