Nodes/ComfyUI-FeiFei/Image To RGB (Force 3-Channel)
ComfyUI Node

Image To RGB (Force 3-Channel)

The boring node that unbreaks your upscaler

By aifeifei798·Created about a month ago·Updated about 12 hours ago· 3
Image To RGB (Force 3-Channel)
  • image
  • image

One input, one output, no widgets. In the pack's own words, it forces an image into a valid 3-channel RGB layout and makes it contiguous, "so NVIDIA RTX VSR / nvvfx can consume it."

That last clause is the whole reason it exists. NVIDIA's RTX video super-resolution nodes read the tensor buffer through raw C++/DLPack pointers rather than going through the usual tensor ops, and they're strict about what they'll accept: 3 channels, channels-last, and a contiguous memory layout. Feed one an RGBA image, or a grayscale frame, or an NCHW tensor that some node upstream produced, and you get a crash or garbage. This is the adapter that fixes it, and it's the kind of node you only learn about by hitting the error first.

Worth knowing why you'd bother: on already-clean sources the community reads RTX VSR output as more natural than generative upscalers - it's closer to a very good Lanczos than to a diffusion model, runs in real time, and won't hallucinate a face that wasn't there. It's the "more pixels, nothing else" path. That's a feature until you hit its input validation, at which point you need this node.

What it actually does

The logic is short and worth reading, because it explains the failure modes:

  1. Normalise to 4 dims. A 2D [H, W] grayscale becomes [1, H, W, 1]; a 3D tensor gets a batch dimension.
  2. Detect channel-first. If the second dimension looks like a channel count (1–4) and the last one doesn't, it permutes NCHW → NHWC.
  3. Force 3 channels. RGBA keeps the first three and drops alpha. Grayscale repeats three times. Two channels gets padded with a black plane. More than four gets truncated to the first three.
  4. .contiguous() - this is the load-bearing line, and the source comment says why: the downstream node reads the buffer through raw pointers, so a non-contiguous view is unusable.

It raises on genuinely bad input (not a tensor, wrong dimensionality, zero channels) rather than guessing, which I'd rather have than a silent reshape.

Using it

Wire your decoded image in, wire the output into the RTX VSR / nvvfx node. That's it - no parameters, so there's nothing to set wrong. If you're not using an NVIDIA hardware path, you don't need this node at all; the stock upscalers are happy with ComfyUI's normal IMAGE tensors.

It's also a harmless no-op if you're unsure. An image that's already 3-channel, channels-last and contiguous comes out identical, at the cost of one copy. Stick it upstream of a picky node and stop thinking about it.

Install

ComfyUI Manager → search ComfyUI-FeiFei, or:

cd ComfyUI/custom_nodes
git clone https://github.com/aifeifei798/ComfyUI-FeiFei.git
# restart ComfyUI; the node is under the FeiFei category

No models, no dependencies beyond torch, which you already have. Nothing in the pack's requirements.txt (numpy, Pillow, openai>=1.40) is touched by this node.

Things to know

  • Alpha is dropped, not composited. If you're feeding a cut-out with transparency and expected the alpha to survive to save time, it doesn't - the output is a flat three-channel image. Do any compositing before this node.
  • The NCHW detection is heuristic. It kicks in when the second dimension is 1–4 and the last dimension isn't, which is right for essentially every real case. It's only ambiguous on absurdly tiny square tensors, and if you're feeding those to an upscaler you have bigger problems.
  • It won't fix dtype or range. This is layout and channel count, not normalisation. An image in the wrong numeric range comes out with the wrong numeric range.
  • Not in the menu? Every node in this pack loads inside its own try/except, so a single import failure doesn't take the pack down. Grep the ComfyUI console for [FeiFei] ImageToRGB failed to load if this one's missing and the rest are present.

Genuinely unglamorous, and that's fine. Some nodes exist to make a graph work rather than to make an image better.

CategoryFeiFei

Inputs (1)

NameTypeDefaultDescription
imageIMAGE—

Outputs (1)

NameTypeDescription
imageIMAGE—