Nodes/ComfyUI Layer Style/LayerUtility: ImageRemoveAlpha
ComfyUI Node Runs on cloud

LayerUtility: ImageRemoveAlpha

ImageRemoveAlpha — flattening a transparent image back to RGB

By chflame163·Created 3 years ago·Updated 5 days ago· 3,113
LayerUtility: ImageRemoveAlpha
  • RGBA_image
  • mask
  • RGB_image
fill_backgroundfalse
background_color#000000

This one does exactly what it says: strip the alpha channel and hand back a plain RGB image. Sounds trivial, but you'll reach for it more than you'd expect, because a lot of what flows through a ComfyUI graph is quietly 4-channel. Any image that's been through a background-removal or matting node, or a PNG loaded straight off disk with transparency baked in, carries an alpha channel - and plenty of downstream nodes (save-as-JPEG, some compositing steps, the occasional encode path) either error on 4 channels or don't handle them the way you'd want.

How it works

Read RGBA_image, look at the alpha channel (or an explicit mask if you supply one), and decide what to do with the pixels that were transparent. If fill_background is off, the alpha channel is simply dropped and you keep whatever RGB values were already sitting underneath it - fine if the source image had sane color data there, risky if it's the garbage color some tools leave in "invisible" pixels. If fill_background is on, those pixels get painted with background_color first, so you get a clean, deliberate flat color instead of whatever noise was hiding under the transparency.

This matters more than it sounds like. The background-removal tooling this pack sits alongside (BiRefNet-style matting, RMBG, and friends) produces alpha as fractional transparency, not a hard cutout - so "just delete the alpha channel" without a fill step can leave a faint ghost of the old background baked into the RGB values at partially-transparent edges.

The inputs and outputs that matter

  • RGBA_image - the transparent image you're flattening.
  • fill_background (default false) - turn this on if you want a solid color under the old transparent area instead of whatever was already there.
  • background_color (default #000000, hex) - only used when fill_background is on.
  • Optional mask - override the image's own alpha channel with a mask you supply, if you want more control over what counts as "background."

Output: RGB_image, plain three-channel, safe to hand to anything that chokes on alpha.

How to install it

Ships as part of the ComfyUI Layer Style pack. In ComfyUI Manager, search ComfyUI Layer Style (or LayerStyle), install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
pip install -r ComfyUI_LayerStyle/requirements.txt

then restart. Lives under 😺dzNodes → LayerUtility. No model download - it's a pixel operation, not an inference step.

Common issues & troubleshooting

Image looks fine at the center but there's a dark or discolored fringe at the edges. That's the classic sign you dropped alpha without filling it. Turn on fill_background and pick a color close to what the final composite's backdrop will be - it removes the ghosting from partially-transparent edge pixels.

The fill color shows up as a hard, unnatural edge. There's no feathering built into this node - it fills based on the alpha (or mask) threshold as given. If you want a soft transition, blur the mask upstream before it reaches this node, not after.

Node isn't in your list at all. That's the pack, not this node. LayerStyle drags in a long dependency chain, and a single conflicting library - transformers next to a stray TensorFlow install is the usual suspect - takes the entire pack down at import, so every LayerStyle and LayerUtility node disappears together. Check the startup console or hit "Try Fix" in Manager.

Category😺dzNodes/LayerUtility

Inputs (4)

NameTypeDefaultDescription
RGBA_imageIMAGE
fill_backgroundBOOLEANfalse
background_colorSTRING#000000
maskoptMASK

Outputs (1)

NameTypeDescription
RGB_imageIMAGE