Nodes/Comfyui HiFORCE Plugin/Convert Image to RGB
ComfyUI Node

Convert Image to RGB

The 30-Second Fix When a Node Hates Your Alpha Channel

By hiforce·Created 3 years ago·Updated 2 years ago· 12
Convert Image to RGB
  • images
  • IMAGE

This node does exactly one thing and it does it in about five lines of code: it takes any image tensor and hands you back a clean 3-channel RGB version. No API calls, no model downloads, no settings to fiddle with. You drop it in when the node downstream refuses to talk to you, and you usually never think about it again.

Here's the situation where it earns its keep. In ComfyUI an image is just a tensor - a batch of H x W x C float values in the 0–1 range. Most of the graph flows as 3-channel RGB, but it doesn't have to. Load a transparent PNG and you've got 4 channels (RGBA). Feed in a grayscale image and you've got 1. And while most nodes handle that gracefully, some encoders and samplers are picky: they want exactly three channels, and they'll throw a shape error or silently produce garbage otherwise. That's what HfImageToRGB is for.

The mechanism is refreshingly blunt. It comes from the HiFORCE pack's shared image library, and the logic is:

  • 4 channels (RGBA) → drop the alpha, keep RGB
  • 1 channel (grayscale) → duplicate it three times
  • anything without a channel dimension → pad up to 3
  • 3 channels already → pass straight through, no work done

So it's a normalization pass, not a filter. Feed it an RGBA image and the output is the RGB underneath, alpha thrown away. Which is worth one warning: it drops alpha, it doesn't flatten it onto a background. A transparent PNG where the RGB values under the alpha are black will come out black in the transparent regions, not white. If what you actually wanted was "cut out onto a white canvas," that's a different tool - this is purely a channel-count converter.

The single images input takes any IMAGE tensor, and the IMAGE output plugs straight into whatever was complaining. You rarely need to touch it more than once in a workflow - usually right after a Load Image that brought in a PNG with transparency.

A couple of honest notes. First, core ComfyUI handles this case well enough most of the time, so this is a "when you hit the wall" node, not a daily driver. Second, it's one half of a pair: HiFORCE ships HfImageToRGBA as the inverse for the (rarer) case where a node insists on four channels. Install one and you get both, so when a mysterious shape error shows up, the fix is usually one of them dropped into the wire.

It ships in Comfyui HiFORCE Plugin, a pack that's mostly known for its sampler nodes (Basic Sampler, Loopback Sampler, HfTwoStepSamplers). These image helpers are the plumbing around them. Install it through ComfyUI Manager by searching "Comfyui HiFORCE Plugin," or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/hiforce/comfyui-hiforce-plugin.git
cd comfyui-hiforce-plugin
pip install -r requirements.txt

Then restart ComfyUI. The README also tells you to install ComfyUI-Impact-Pack first - many of the pack's optimizations build on it, so it's a good idea even if the image converters themselves don't strictly need it. The requirements.txt is just torch, numpy, Pillow, and requests, all of which your ComfyUI install already has, so nothing heavy gets pulled in and no models are downloaded.

One last thing: this pack gets almost no discussion on Reddit or elsewhere - it's a niche, author-maintained pack you mostly discover through Manager. When something surprises you, the source is short and readable, and the GitHub wiki is the real documentation.

CategoryHiFORCE/Image/Convert

Inputs (1)

NameTypeDefaultDescription
imagesIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE