ColorMod (compress)
What to do with values outside 0–1
- image
- IMAGE
Sooner or later in this pack, you'll have an image whose pixels live outside [0, 1]. Maybe you moved brightness with clip off to build an HDR pass, or you tonemapped something and it overshot. The VAE doesn't like that - diffusion models were trained on [0, 1] and behave oddly with out-of-range input. ColorMod (compress) is the small utility that gets you back into range, and it gives you three different philosophies for doing it. It's the "safety valve" node of the pack, and it rarely gets the credit it deserves.
The inputs
Just two:
image- the IMAGE to fix.mode- a dropdown with three choices:- clip - hard-clamp everything to
[0, 1]. Simple, predictable, loses dynamic range. Fine for mild overshoot. - normalize - rescale so the image's min becomes 0 and its max becomes 1. Preserves relative contrast and makes full use of the range, but it throws away absolute brightness: an image that's supposed to be dark overall gets stretched bright.
- compress - folds out-of-range values back inside
[0, 1]instead of cutting them off. A pixel at 1.3 comes back around to 0.3; a pixel at −0.2 comes back to 0.2. It's a mirror-style fold, and it keeps midtones roughly intact while reining in the extremes.
- clip - hard-clamp everything to
Output is one IMAGE in [0, 1], guaranteed (the node clips as a sanity check regardless of mode).
Installing
cd ComfyUI/custom_nodes
git clone https://github.com/city96/ComfyUI_ColorMod
cd ComfyUI_ColorMod
pip install -r requirements.txt
Restart, or install via ComfyUI Manager ("ComfyUI_ColorMod"). Pure PyTorch - no pypng, no opencv needed.
How to pick a mode
My honest advice: clip for most cases, normalize when you know what you're doing. Clip is what you want 95% of the time when the overshoot is small - it just tidies the range with zero surprises. Normalize is the better tool when the whole image is offset (say you moved everything +0.5 and want the range re-expanded), but remember it re-maps brightness, so "what should be a dark scene" becomes "what should be a normal-brightness scene."
Compress is the weird one, and I'd use it sparingly. The fold means a bright 1.3 highlight and a 0.3 midtone end up indistinguishable - that destroys information in exactly the values HDR was trying to preserve. It exists for the case where you have mild out-of-range values and want them "tucked back in" without losing the overall distribution, and it works - but clip does the same job with less cleverness. When in doubt, clip.
Where it fits
Wire it right before a VAE encode, a KSampler, or any node that assumes [0, 1]. It's also the clean way to test whether your "odd behavior" is actually out-of-range pixels: stick this on with clip and see if the weirdness disappears. That single diagnostic is worth the install by itself.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mode | COMBO | 3 options: clip, normalize, compress |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |