ConvertToGrayscale
The one that respects your alpha channel
- image
- IMAGE
Converting an image to grayscale sounds like a solved problem - then you try it in ComfyUI and discover half the "grayscale" nodes silently throw away your alpha channel, or hand you a shape downstream nodes choke on. ConvertToGrayscale is the small, careful version from the Eden pack that handles the two edge cases everyone else forgets: it works on RGBA images without nuking the alpha, and it keeps your channel count intact.
It's a plumbing node, not a headline feature, but plumbing nodes are what actually make a workflow run. One input, one output, and it does exactly what it says.
How it works
The conversion itself is the standard Rec. 601 luminance formula - weighted sum of R, G, B with the classic coefficients 0.2989, 0.5870, 0.1140 - matching how a TV or a thoughtful image editor converts to gray, with green weighted heaviest because that's how human vision actually works. Two details make it worth having:
- It keeps your dimensions. A 3-channel RGB image comes back as 3-channel grayscale (all channels identical), and a 4-channel RGBA image comes back 4-channel. No surprise channel-count changes that break a downstream node expecting RGB.
- It handles alpha deliberately. When there's an alpha channel, the
alpha_channel_convert_tovalue (0β1, default 0) sets what color transparent pixels become. Transparent areas get blended toward that value - so at 0, fully transparent pixels become black; at 1, white. This is the part other grayscale nodes botch by just flattening or discarding alpha.
If you feed it a single-channel image already, it returns it untouched. Anything with 1, 3, or 4 channels is handled; anything else raises a clear error instead of silently misbehaving.
Inputs and outputs
- image - your IMAGE tensor.
- alpha_channel_convert_to - a float 0β1 (default 0) setting the gray value for transparent pixels in RGBA inputs. Ignored for RGB images.
Output is a single IMAGE of the same batch size, height, width, and channel count as the input, just gray.
When you'd reach for it
The honest uses: prepping an image for a depth-style preprocessor that wants gray, building luminance masks (a grayscale image is a soft mask if you convert it to MASK), or normalizing inputs for nodes that behave better on gray. The alpha handling makes it the right pick when your source is a transparent PNG or a composited RGBA frame - exactly the kind of input that makes naive converters spit out black boxes where transparency used to be.
Installing
One of 70+ nodes in edenartlab/eden_comfy_pipelines (Eden.art nodesuite):
cd ComfyUI/custom_nodes
git clone https://github.com/edenartlab/eden_comfy_pipelines.git
cd eden_comfy_pipelines
pip install -r requirements.txt
Restart ComfyUI, or install via ComfyUI Manager (search "Eden"). Pure torch math, no model downloads, no extra dependencies.
Gotchas
The output is grayscale but still 3 or 4 channels - if you're feeding it somewhere that specifically wants a single-channel MASK, convert afterward. And if your input is already grayscale, remember it short-circuits and returns immediately - don't expect the alpha-convert value to do anything in that case. Otherwise there's not much to trip on; it's about as simple as the schema suggests.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| alpha_channel_convert_to | FLOAT | 0.000β1 | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | β |