Loop Strip — Ensure RGB
The boring node that un-breaks your workflow
- image
- IMAGE
Some nodes are heroes, some are the unsung ones that stop the whole graph from exploding. This is the second kind. Ensure RGB takes any image tensor and forces it into the [B, H, W, 3] shape that downstream ComfyUI nodes expect. It fixes grayscale, alpha, and weird channel-layout images before they trip over something downstream.
You hit this node's use case the moment you start chaining segmentation into the Loop Strip pipeline. The author's own docstring names the enemy: the "RMBG squeeze bug" - background-removal models that return a 4-channel RGBA image where a downstream node only tolerates 3. One red wire from Center Character to a node that refuses alpha and your run dies with a cryptic shape error. Slip Ensure RGB in between and the error evaporates.
How it works
It's a shape-normalization matcher. From the source, it handles every case a real workflow throws at it:
- 2D
[H, W]grayscale → becomes[1, H, W, 1], then channels repeat to 3. A grayscale image becomes a proper RGB image, just with R=G=B. - 3D input - the heuristic looks at the last dimension: if it's ≤ 4 it treats the tensor as
[H, W, C], otherwise as a grayscale batch[B, H, W]. It guesses, and it guesses right for the shapes that actually occur. - 1 channel → repeated to 3. 4 channels (RGBA) → alpha dropped. 2 channels → duplicated up. More than 4 → truncated to 3.
In every case the output is a contiguous [B, H, W, 3] batch, ready for anything.
The one input, the one output
Just image in, IMAGE out. There are no settings to mis-set, which is exactly the point of a node like this. Drop it inline anywhere a shape error appears and it either fixes it or tells you - loudly, in the console, with a [LoopStrip] EnsureRGB: old → new line - exactly what it did.
Install
Same pack, same routine. ComfyUI Manager → search "Loop Strip" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/serhiiyashyn-sf/comfyui-loopstrip
cd comfyui-loopstrip
pip install -r requirements.txt
Restart afterwards. The pack's requirements (opencv-python, numpy, torch, scipy, requests) are already present in a standard ComfyUI install, and nothing needs downloading.
Where it fits
Think of it as a fuse. You won't put it in your main path out of habit - but the first time a background-removal node hands you an RGBA tensor and something downstream chokes, you'll be glad it exists. It's also the cheapest possible debug step for "why won't this connect": route through Ensure RGB and confirm the shapes yourself.
It won't save you from every mismatch - if you need a mask and have an image, or need a specific resolution, this node is not your answer. But for the narrow, maddening class of "one extra channel wrecked my run" problems, it's a one-wire fix. Boring, and exactly what you want from boring.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |