Nodes/LiamUtil/Image To Gray @Liam
ComfyUI Node

Image To Gray @Liam

A one-input grayscale converter that keeps 3 channels

By ai-liam·Created 2 years ago·Updated 2 years ago· 2
Image To Gray @Liam
  • image
  • IMAGE

The simplest useful node in the pack: feed it an image, get the same image in grayscale. If that sounds like something a filter or a KSampler pass could do, you're not wrong - but there's a niche here. Depth maps, masks, and engraving-style inputs are naturally monochrome, and when you're chaining preprocessing nodes you often just want "make this gray, cheaply, without thinking about it."

The neat implementation detail is that it doesn't return a single-channel image. It converts to luminance and then replicates it back into all three RGB channels, so the output is still a standard 3-channel IMAGE tensor. That matters in ComfyUI: plenty of downstream nodes assume 3 channels, and a lone gray channel quietly breaks things. You get a grayscale-looking image that behaves like any other color image.

Inputs and outputs

Exactly one required input: image (an IMAGE tensor - the output of a Load Image, VAE Decode, or any image node). One output: IMAGE, same dimensions as the input, now gray.

There's nothing else to set. No threshold, no contrast, no "which channel" - it's a straight convert("L") in PIL terms.

How it works

The node converts the tensor to a PIL image, calls convert("L") for luminance, then merges that single channel back into an RGB image with Image.merge. That's the whole mechanism - pure PIL, no model, no network, runs in milliseconds.

Installing it

Part of LiamUtil:

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

or ComfyUI Manager → search LiamUtil → install → restart. Then restart ComfyUI. Only dependency is opencv-python (used elsewhere in the pack).

Where people get burned

Honestly, the main trap is the batch dimension. The code does tensor.numpy().squeeze(), which drops every size-1 dimension and assumes a single image. Feed it a batch of several images and the squeeze leaves you with a 4D array that PIL will refuse to open - so send one image at a time, or process a batch with the node wired per-frame. Also, since the result is three identical channels, don't expect it to shrink your memory footprint or speed anything up; a true single-channel pipeline would need a different node. For what it is - a quick, dependable grayscale step that stays downstream-friendly - it does the job without surprises.

CategoryLiam/Image

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE