Nodes/ComfyUI-ArchiGraph/To Image πŸ¦β€πŸ”₯
ComfyUI Node

To Image πŸ¦β€πŸ”₯

The bridge back β€” from OpenCV arrays to normal ComfyUI images

By vincentfsΒ·Created 2 years agoΒ·Updated 9 months agoΒ· 3
To Image πŸ¦β€πŸ”₯
  • nparrays
  • images

Every ArchiGraph OpenCV node hands you a NPARRAY - a numpy array in OpenCV's world of 8-bit, 0–255, BGR-channel data. And every normal ComfyUI node expects an IMAGE - a float 0–1, RGB torch tensor. Those two worlds do not talk to each other without a translator. This node is the translator on the way back out.

Why you'd reach for it

Because it's the only way to see or use your OpenCV results. Run a Sobel, a threshold, a contour pass - the output is an NPARRAY, and you can't preview it, save it with a normal Save Image node, or feed it into VAE encode or ControlNet. To Image converts it to a standard IMAGE so everything downstream just works. In any non-trivial ArchiGraph workflow, this node (or its output-save cousins) is the mandatory exit ramp from the OpenCV half of the graph.

How it works

It loops over each array in the batch and normalizes it into the IMAGE type. Grayscale arrays - either 2D (H, W) or single-channel (H, W, 1) - get expanded to three identical channels so they render as gray. Three-channel arrays are assumed to be BGR (OpenCV's native order) and are flipped to RGB. Each frame is then rescaled from 0–255 integers to float 0–1 and moved to ComfyUI's compute device as a torch tensor, and the batch is stacked back together.

The inputs and output

One required input: nparrays, the array or batch of arrays to convert. The single output is images, a standard IMAGE - meaning whatever comes out of this node can plug into absolutely anything in normal ComfyUI.

Installing it

Part of ComfyUI-ArchiGraph: ComfyUI Manager β†’ search "ArchiGraph" β†’ install β†’ restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/vincentfs/ComfyUI-ArchiGraph
cd ComfyUI-ArchiGraph
pip install -r requirements.txt   # or install.bat / install.sh

Where people get burned

The channel-order assumption is the classic gotcha. This node assumes your array is BGR, which is correct when the array came from AG To Nparray (that node converts RGB→BGR for you) or from any cv2 function. But if you feed it an RGB array - say you built one yourself or loaded something in standard order - your "image" comes out with red and blue swapped. The round trip through To Nparray is safe; everything else is on you.

Second, the value-range assumption. It treats the input as 0–255 and divides by 255. A float 0–1 array will produce a nearly black image, which is why float arrays keep causing "black preview" confusion across this pack. Third, only the three cases above get channel conversion. A 4-channel array slips through the branches with no color conversion at all - you'll get whatever raw values were there, which is almost never what you wanted. Keep your arrays 2D or 3-channel.

CategoryπŸ¦β€πŸ”₯ ArchiGraph/πŸ“€ OpenCV

Inputs (1)

NameTypeDefaultDescription
nparraysNPARRAYβ€”

Outputs (1)

NameTypeDescription
imagesIMAGEβ€”