Nodes/ComfyUI_StarNodes/⭐ Star RGBA Converter
ComfyUI Node

⭐ Star RGBA Converter

The fourth channel ComfyUI keeps forgetting about

By Starnodes2024·Created 2 years ago·Updated a day ago· 107
⭐ Star RGBA Converter
  • image
  • image
◄modeRGBA To RGB►

The 3-channel assumption nobody tells you about

ComfyUI's IMAGE type is a float tensor shaped [batch, height, width, channels], and channels is almost always 3. Load a PNG with transparency into the core Load Image node and you get RGB back - the alpha is split off into a separate MASK output and the image itself goes through convert("RGB"). That's why most ComfyUI workflows never think about alpha at all: the core pipeline quietly refuses to carry it.

Then something in your graph does. A transparent-generation node, a background remover that writes alpha into the image rather than into a mask, a PSD or icon pipeline, whatever RGBA-flavoured tool you just added. Suddenly there's a 4-channel tensor on the wire, and a whole class of downstream nodes assumes 3 - VAE Encode, anything doing per-channel maths, some save nodes, plenty of third-party filters. Best case you get a shape error; worst case you get an image that looks subtly wrong with no complaint at all, because some nodes just silently drop the alpha channel and hand you something flattened.

⭐ Star RGBA Converter is the adapter for exactly that boundary.

How it works

This is the simplest node in the pack, and the source is about thirty lines. It reads the last dimension and does one of three things:

  • RGBA To RGB on a 4-channel tensor → returns image[:, :, :, :3]. The alpha slice is gone.
  • RGB To RGBA on a 3-channel tensor → concatenates a torch.ones_like alpha channel, so the result is fully opaque.
  • Anything else → returns the image untouched.

Because it only ever looks at the last axis, batching works with no special handling.

Notice what RGB To RGBA is not: it can't create transparency. There's no alpha hiding in a 3-channel image to recover, and generating it is a model problem rather than a post-processing one - LayerDiffusion's approach was to bake latent transparency into sampling so edges come out right by construction, because nothing afterward can reconstruct them. The real use of this mode is the other direction of the same mismatch: a downstream node that insists on four channels and throws on three.

The two inputs, and the one output

You set two things: image, and mode, a two-option dropdown (RGBA To RGB, default, or RGB To RGBA). No optional inputs, no tooltips to decode.

The lone output is image - the converted tensor. Wire it into whatever was complaining. The practical rule: put it right at the boundary where your graph leaves the alpha-aware part of the pipeline and re-enters the 3-channel world, not at the very end after five more nodes have already choked.

Where people get burned

RGBA To RGB drops alpha, it does not composite it. This is the big one. Slicing the channel off leaves the RGB values underneath the transparent pixels exactly as the producer left them - frequently black, sometimes garbage. If what you wanted was the subject flattened onto white, over a backdrop, or onto another image, you want a composite node, not this. And if you needed the alpha as a usable mask, this node doesn't hand you one; there's no mask output.

Silent pass-through. If the channel count doesn't match the mode you picked, you get your input back unchanged and no error. So "the node does nothing" almost always means the tensor was already the shape you asked for, or you picked the wrong direction. Diagnose by printing image.shape - or use the pack's ⭐ Star Show Everything debug node, which prints type, shape and stats for anything you plug into it.

Premultiplied alpha will leave halos. If the source was stored premultiplied, the RGB values are already multiplied by alpha, so slicing the alpha off darkens every semi-transparent pixel - a dark fringe around hair, fur and soft edges. Fix that upstream, before the alpha is thrown away.

Half of a pipeline can carry alpha and half of it can't. Transparency support in ComfyUI is per-node, not a property of the format. If you're assembling an RGBA chain, test each hop and check what came out the other side.

Install

ComfyUI Manager, search Starnodes, install, restart. Or the manual route:

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

Those requirements are for the pack's other nodes (psd-tools, opencv-python, imageio-ffmpeg, ollama). This node is pure core plumbing plus PyTorch - no dependency of its own, and the pack's install.py intentionally installs nothing, so a missing package only skips the node that needs it. Find it under double-click → search star, category ⭐StarNodes/Image And Latent. It's one of 100+ nodes from a solo dev who ships updates constantly, so if it doesn't show up, restart ComfyUI before assuming the install failed.

Category⭐StarNodes/Image And Latent

Inputs (2)

NameTypeDefaultDescription
imageIMAGE—
modeCOMBORGBA To RGB2 options: RGBA To RGB, RGB To RGBA

Outputs (1)

NameTypeDescription
imageIMAGE—