Image Remove Alpha
Flatten transparency onto a hex background — Image Remove Alpha composites by mask
- images
- masks
- images
Some consumers of images - JPEG save paths, certain upscalers, image hosts - simply do not want transparency. Image Remove Alpha takes an RGBA image plus a mask and composites it over a solid background color you specify as a hex string, handing back a flat RGB image with nothing transparent left in it.
The name is a slight oversimplification, which is worth knowing before you pick it over the pack's Fill Alpha node. It doesn't just "drop the alpha channel" - dropping alpha without compositing gives you black or garbage where the transparency was. This node actually composites: it takes your image and pastes it onto a solid fill_color background using a mask that encodes where the image is opaque. That's why it needs the separate masks input - the transparency information is expected to arrive as a MASK, not baked into the image's own alpha.
The mechanism, from the source, is a straightforward PIL paste. For each image/mask pair: create an RGBA canvas in the fill color, paste the image using 1 − mask as the paste mask, convert the result to RGB. The 1 − mask inversion is the subtle part - ComfyUI masks are white-where-present, but PIL's paste mask is white-where-you-keep-the-pasted-image, so the node flips it to match.
The inputs:
- images - the image batch to flatten.
- masks - the transparency masks; required, one per image.
- fill_color - the background color as a hex string like
#FFFFFF, default white.
The output:
- images - the flattened RGB batch.
Where it fits: any pipeline that needs a transparent asset delivered on a solid background - product renders onto white, cutouts onto a brand color before a save node that hates alpha, or a pre-JPEG step where transparency would be silently destroyed anyway. In the FairLab pack it pairs with Fill Alpha, which reads transparency from the image's own alpha channel instead of a separate mask. Use Image Remove Alpha when your transparency lives in a mask (which is common when the mask came from a background-removal node); use Fill Alpha when it's in the image's RGBA alpha.
Honest caveats: both inputs are required, so you can't feed it a plain RGBA image with no mask and expect it to work - wire the mask in. And the hex string is parsed by PIL's Image.new("RGBA", size, fill_color), which expects a #RRGGBB form; a bare color name like "white" may not parse. Keep the # format and you're fine.
Install is the standard pack path: ComfyUI Manager → search ComfyUI-FairLab → install → restart:
cd ComfyUI/custom_nodes
git clone https://github.com/yanhuifair/ComfyUI-FairLab.git
cd ComfyUI-FairLab
pip install -r requirements.txt
Restart, search "Image Remove Alpha" or "flatten rgba". No models, no heavy deps - PIL compositing only.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| masks | MASK | — | |
| fill_color | STRING | #FFFFFF | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |