Nodes/ComfyUI Layer Style/LayerUtility: Gray Value
ComfyUI Node Runs on cloud

LayerUtility: Gray Value

Gray Value — turn a color into a plain brightness number

By chflame163·Created 3 years ago·Updated 5 days ago· 3,113
LayerUtility: Gray Value
  • color_value
  • gray(256_level)
  • gray(100_level)

This one isn't an image node at all - it's a data-utility node. Feed it a color and it hands back that color's brightness as a plain integer. You reach for this when a color needs to drive a number somewhere else in your graph - an opacity slider, a threshold, a sort key, a conditional branch - rather than sit on the canvas as pixels.

A practical example: chain Get Main Colors to pull the dominant color off a background photo, run it through Gray Value, and use the result to decide whether text overlaid on that background should be light or dark - bright background, dark text, and vice versa - all without ever looking at the image yourself.

How it works

It converts the incoming color to luminance using the standard weighted RGB-to-gray formula (green counts for more than red or blue, because human vision is more sensitive to green) and reports the result on two different scales. That weighting matters more than it looks - a pure green and a pure blue at the same "intensity" don't produce the same gray value, which is exactly why this node exists instead of just averaging the three channels; a naive average would misjudge how bright a color actually reads to the eye.

The inputs and outputs that matter

One input - color_value - which is untyped, meaning it'll accept a color string coming out of any color-producing node in the pack (Get Main Colors, Name To Color, or a plain hex string typed into a text node).

Two outputs: gray(256_level), the familiar 0–255 8-bit brightness scale, and gray(100_level), the same value rescaled to 0–100 - useful when whatever you're feeding it downstream expects a percentage-style slider instead of the raw 8-bit range.

How to install it

Search ComfyUI Layer Style in ComfyUI Manager, or:

cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
pip install -r ComfyUI_LayerStyle/requirements.txt

Restart; it's under 😺dzNodes → LayerUtility → Data. Nothing extra to download - it's a one-line math conversion.

Common issues

Because color_value accepts "anything," the failure mode isn't a wrong number, it's an outright error - if you plug in something that isn't actually parseable as a color (a raw string that doesn't resolve to a hex value, say), the node throws instead of quietly returning zero. If it errors on you, the fix is almost always upstream: check what's actually connected and make sure it's genuinely producing a color, not just text that looks color-adjacent. Beyond that there's really nothing to troubleshoot - it's a small, honest conversion node, and it does exactly the one thing it says it does. If your downstream logic seems to be making the "wrong" light/dark decision, double check whether it's reading gray(256_level) where it should be reading gray(100_level) (or vice versa) - mixing up the two scales is the most common self-inflicted bug here, since both outputs fire every run whether you use one or both.

Category😺dzNodes/LayerUtility/Data

Inputs (1)

NameTypeDefaultDescription
color_value*—

Outputs (2)

NameTypeDescription
gray(256_level)INT—
gray(100_level)INT—