Nodes/ComfyUI-TextureAlchemy/Get Average Color ๐ŸŽจ
ComfyUI Node

Get Average Color ๐ŸŽจ

One node that answers 'what color IS this texture?'

By amtarrยทCreated 9 months agoยทUpdated 4 months agoยท 58
Get Average Color ๐ŸŽจ
  • image
  • mask
  • hex_color

Every once in a while you stare at a texture and need its average color - to match a background, to pick a tint, to feed a hex value into a color input somewhere else in your graph. You could screenshot it, open an image editor, and sample it, like an animal. Or you could drop this node in, run the graph, and read the hex_color off the output. It's the smallest possible node - one input, one output - and it does exactly one thing, but that one thing comes up more often than you'd think.

The behavior is simple: it averages the pixels of the image and formats the result as a hex string like #8A6B4F, which it hands you as a STRING output. Since ComfyUI's graph can carry strings between nodes, that hex value isn't just for reading - it can feed directly into anything with a color-as-string input, like the pack's Crop to Mask (with Padding) custom_color field, or any node that wants a hex color. That wiring-friendly design is the reason it exists in a texture pack rather than being a manual chore.

The input that makes it more than a toy is the optional mask. Pass a mask in and the average is computed only over the visible (white) regions, ignoring the blacked-out areas entirely. That's the difference between "average of the whole brick wall" and "average of the mortar joints specifically" - a genuinely useful distinction when you're sampling a color for a purpose. It resizes the mask to the image if needed and weights the average accordingly, so you can use a rough selection without pixel-perfect alignment.

One implementation detail worth knowing: it averages the first image in the batch, so a batched input only contributes its first frame. In practice that's fine - you're nearly always passing a single image. And it's all tensor math, so it's instant.

Output is a single STRING: hex_color. That's it. Wire it to a text display, or into a downstream node that consumes hex.

Where it fits the pack: it's a utility in the truest sense, the kind of node you forget exists until you need it. The pack's Texture Equalizer uses the same "average color" concept internally, and the README even suggests using this node's sibling output for debugging - same spirit. If you're building a material workflow and you want to match a weathering tint to the base albedo, this is the fastest honest way to get that number.

Install: Manager โ†’ search "Texture Alchemy", or:

cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy

Restart, then Texture Alchemist/Color โ†’ Get Average Color. No dependencies, no models. Shared gotchas: the README's manual-copy step references the pack's old folder name, and a blocked Git-URL install is ComfyUI's security level - clone by hand.

CategoryTexture Alchemist/Color

Inputs (2)

NameTypeDefaultDescription
imageIMAGEโ€”
maskoptMASKOptional mask to only average visible regions

Outputs (1)

NameTypeDescription
hex_colorSTRINGโ€”