ComfyUI Node

AutoColorGimp

GIMP's Auto White Balance, ported into ComfyUI

By A4P7J1N7M05OT·Created 2 years ago·Updated 2 years ago· 1
AutoColorGimp
  • img
  • image
threshold145

Your image came out of the sampler flat, muddy, and wearing a color cast you didn't ask for. You could open GIMP, hit its Auto White Balance filter, and save. Or you could wire this one-input node into the graph and never leave ComfyUI. AutoColorGimp is exactly that filter, ported as a single post-processing node. No models, no API key, no CUDA - the entire pack is one README line pointing at a StackOverflow answer, and one node that runs pure numpy/OpenCV math on the CPU.

What it actually does

It's a per-channel histogram stretch, the same thing GIMP's "Auto White Balance" (or auto-levels, if you squint) does. For each RGB channel it builds a 256-bin histogram, throws away the bins that hold fewer than 0.05% of the pixels - the clipped ends of the data - then stretches whatever's left across the full 0–255 range. Each channel is stretched independently, so a faded old photo with a greenish cast gets its contrast and its color balance fixed in a single pass.

A couple of honest caveats before you get excited. This is not gentle "make the whites white" white balance. Because it stretches each channel on its own, it happily pushes saturation and contrast harder than a human grader would. The photorealism playbook in the community knowledge base keeps telling people to pull saturation down; this node runs the other way. It's a rescue tool for washed-out images, not a finishing grade.

The threshold twist

Here's where the node gets clever, and weird. Before committing, it does a trial normalization, then measures how much the per-channel histograms would actually change using chi-square distance (that's the scipy dependency). Only if that change stays under your threshold does it apply the correction. If it decides not to bother, it returns your image untouched and prints Difference between normalized and original is too high (X), skipping. in the ComfyUI console.

Practical consequence: badly faded images - the ones that need the most dramatic rescue - are exactly the ones it tends to skip at the default setting. That's why you have the two inputs that matter:

  • img (IMAGE) - feed it one RGB image at a time (see the gotcha below).
  • threshold (INT, default 145, range 0–99999999) - not a strength slider. It's the cutoff for "is the correction worth it." Set it to 0 to always force the correction; raise it whenever the console says it's skipping, using the printed X as your guide.

Output is a single image (IMAGE) of the same size, ready to chain into the next post-processing node or straight into Save Image.

Where people get burned

  • Batching. The node squeezes the batch dimension and hands the result to OpenCV's cvtColor, which expects a single 3-channel image. Feed it a batch of several and it throws. One image at a time.
  • Silent skips. It doesn't error when it decides not to correct - it just returns the input unchanged. If nothing seems to happen, check the console for that "too high" line and bump the threshold.
  • The repo itself. As of this writing the original GitHub repo comes back 404, and the code lives on through the copy comfy.icu indexes (a mirror fork preserves it). If a manual clone fails, that's why - use ComfyUI Manager instead.

Installing it

Easiest route is ComfyUI Manager: search for "AutoColorGimp" and install, then restart ComfyUI. Manual route, same as any custom node:

cd ComfyUI/custom_nodes
git clone https://github.com/A4P7J1N7M05OT/ComfyUI-AutoColorGimp

Then restart. It declares torch, opencv-python, numpy, and scipy as dependencies - Manager handles those for you; if you install manually, make sure opencv-python and scipy are present in your Python environment or the node won't import.

Is it the node you'll reach for every day? Probably not - it's a one-trick utility from an anonymous author. But when a generation comes out flat and you'd rather not fire up GIMP, it's a nice little button to have in the graph.

Categoryimage/postprocessing

Inputs (2)

NameTypeDefaultDescription
imgIMAGE
thresholdINT1450–99999999

Outputs (1)

NameTypeDescription
imageIMAGE