ComfyUI Node

To RGB

Flatten a batch of images down to plain 3-channel RGB

By hben35096·Created 2 years ago·Updated about a year ago· 8
To RGB
  • images
  • images

To RGB does one thing: it takes a batch of images and forces every one of them down to plain 3-channel RGB, dropping alpha or any other extra channel that snuck in along the way. One input, one output, nothing to configure. If you've ever had a node three steps downstream throw a cryptic shape or channel-count error and traced it back to an image that turned out to be RGBA when everything else was RGB, this is the fix - insert it right before the point of failure.

This isn't a novel idea - plenty of packs ship a "strip alpha" node, because plenty of sources hand you RGBA without asking: PNGs with transparency, background-removal output, some loaders, screenshots. What makes this particular one worth having is where it lives. It ships inside ComfyUI-ReplenishNodes, a pack the author built as small helper nodes for XY-plot comparison workflows (the README points you at qq-nodes-comfyui, images-grid-comfy-plugin and Impact-Pack as the actual grid-building tools). Grid and batch-comparison nodes stack multiple images into one tensor, and that stacking breaks the moment one image has four channels and its neighbors have three. To RGB is the node you run across your whole batch right before assembly so a single stray RGBA image doesn't blow up the grid.

How it works

Standard RGBA has four channels per pixel - red, green, blue, and alpha (opacity). To RGB discards the alpha channel and hands back plain 3-channel color data. It's a flatten, not a composite: it doesn't blend the transparency onto a background color, it just removes the channel. If you need transparent areas filled with a specific color rather than silently dropped, composite the image over a solid background first and run this afterward - for straightforward "stop erroring on channel count," it's exactly what you want.

The inputs and outputs that matter

  • images - the batch to flatten. Already-RGB images pass through essentially unchanged; anything carrying a fourth channel gets it stripped.

The single output, images, is the same batch guaranteed 3-channel. Wire it straight into whatever was complaining - a grid node, a save node, a comparison tool - and the channel mismatch is gone.

How to install it

Via ComfyUI Manager: Install Custom Nodes, search ComfyUI-ReplenishNodes, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/hben35096/ComfyUI-ReplenishNodes

then restart. This node is pure tensor manipulation - no models, no extra dependencies. As with the rest of the pack, it's meant to sit alongside qq-nodes-comfyui, images-grid-comfy-plugin and ComfyUI-Impact-Pack if you're building the XY-grid workflow it was written for, rather than being pulled in on its own.

Common issues & troubleshooting

A downstream node errors with something like "expected 3 channels, got 4." That's the textbook case this node exists for. Drop it in right before the node that's complaining.

My transparency disappeared, or the background went black/opaque. Expected - this node removes alpha rather than preserving it. If you need the transparent regions to stay meaningful, composite over a background color before converting, or skip this node entirely.

Still errors after converting. The mismatch probably isn't alpha at all - check for a batch-size mismatch, a mask being fed where an image is expected, or images at different pixel dimensions (that last one is what this pack's other node, Reference Resize, is for - running both before a grid/compare step is the combo the pack is built around).

Node missing after install. Make sure the folder under custom_nodes is literally named ComfyUI-ReplenishNodes and that you did a full restart rather than a browser refresh - the usual custom-node-didn't-load checklist applies here same as anywhere else.

CategoryReplenish/Image

Inputs (1)

NameTypeDefaultDescription
imagesIMAGE

Outputs (1)

NameTypeDescription
imagesIMAGE