GrayscaleImage
The grayscale node that won't quietly kill your alpha channel
- images
- IMAGE
Grayscale is one of those operations you assume core ComfyUI handles natively. It doesn't, really - the built-in options are oddly sparse, so you end up reaching for a custom node. This one from the Image-Toolkit pack is about as boring as a node can get, and that's mostly a compliment: it converts your image to grayscale, keeps the channel count you gave it, and doesn't mangle your transparency in the process.
Here's why that last part matters. ComfyUI passes images around as float tensors in BHWC layout, where C can be 3 (RGB) or 4 (RGBA). Plenty of grayscale utilities happily throw away the alpha channel or, worse, convert to a 1-channel tensor that downstream nodes then refuse to touch. GrayscaleImage avoids all of that by preserving the alpha channel when it's present. Feed it an RGBA image and you get an RGBA image back - gray RGB values, original alpha intact.
How it works
Under the hood it delegates to a shared helper in the pack that uses OpenCV's cvtColor (COLOR_RGB2BGR, then COLOR_BGR2GRAY). That means it applies the standard luminance weighting - roughly 0.299 red + 0.587 green + 0.114 blue - rather than just averaging channels. Your eye is more sensitive to green than blue, so this produces a grayscale that actually matches perceived brightness. The gray value then gets copied into all three channels so the output is a proper RGB tensor, and any alpha channel rides along untouched.
It also handles batches: hand it a stack of images (say, an animation's frames or a batch from an image-to-image loop) and each one gets converted in turn. Everything runs on CPU in numpy/OpenCV - no model, no VRAM, nothing to download.
The inputs that matter
Just one, and it's the obvious one:
images(IMAGE) - the image or batch to convert. That's it. No threshold, no mode toggle, no knobs to fiddle.
The output is a single IMAGE tensor you can wire into anything that expects color images. That's the neat trick of keeping the output 3- or 4-channel: you can drop this node in front of nodes that require RGB without reworking the rest of your graph.
Where you'd actually use it
The realistic uses are pre-processing, not aesthetics. It's a sensible first step before BinarizeImage (also in this pack) when you want to control exactly how luminance maps to black and white, a cheap way to make a mask-like image for debugging, or a way to check whether a texture reads correctly in luminance before you commit to a workflow that keys off brightness. It's also a quieter way to do what BrightnessTransparency does partway: brightness info, but as gray instead of alpha.
Installing it
Same story as every node in this pack - it's part of keit0728/ComfyUI-Image-Toolkit:
cd ComfyUI/custom_nodes
git clone https://github.com/keit0728/ComfyUI-Image-Toolkit
Then restart ComfyUI. Or just install "ComfyUI-Image-Toolkit" via ComfyUI Manager's node search and let it handle the clone. The only dependency is opencv-python==4.11.0.86, which is pinned to an exact version - that's also the one thing that can make the install look stuck, since pip may need to downgrade or upgrade an existing OpenCV install.
Gotchas
Two small ones. First, the pack's own README ships a copy-paste placeholder clone URL (https://github.com/your-username/...) - the real repo is keit0728/ComfyUI-Image-Toolkit, so don't be confused if the README line doesn't match. Second, this is a tiny, near-anonymous pack (one of its nodes has literally a single Google impression), maintained as a personal tool by a Japanese author whose code comments are still in Japanese. It works fine, but there's no support channel and no issue queue to lean on - for a node this simple, that's a fair trade.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | Converts images to grayscale. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |