Image Normalize -1 to 1 (Swwan)
The two-line node that exists for range picky consumers
- images
- IMAGE
ComfyUI's IMAGE type is a float tensor in the range 0–1. Every loader produces that, every saver expects it back, and almost everything in between is happy. Almost.
Some consumers - preprocessors ported from research repos, geometry and mesh nodes, a handful of comparison and difference operations, anything that was written against a [-1, 1] convention - will happily accept 0–1 input and give you an image that looks like it was shot through grey glass. Nothing errors. The pixels are just wrong.
This node is the fix, and it is genuinely two lines of arithmetic: images * 2.0 - 1.0.
Interface
Input: images (IMAGE). Output: IMAGE.
That's it. No options, no clamping, no inverse. The pack's description says "Normalize the images to be in the range [-1, 1]," which is exactly what it does to a properly ranged input: 0 becomes -1, 1 becomes 1, 0.5 becomes 0.
Note what it is not doing. This is not statistical normalization - it doesn't compute a mean and standard deviation, doesn't touch per-channel statistics, and won't rescue an image whose values are outside 0–1. If your tensor is already out of range, this multiplies the problem by two. It is a linear remap and nothing else.
When you actually need it
- A consumer whose docs say
[-1, 1]. Follow the docs. This is 90% of the use. - Difference and comparison math. Subtracting two 0–1 images gives you a result mostly in 0–0.2 with everything negative clipped to black. Remapping both to -1..1 first makes subtraction and signed difference visually meaningful.
- Feeding a downstream node that expects signed input (some normal-map-ish or coordinate-ish tooling).
And the inverse direction: if a node hands you output in [-1, 1] and you want to save or preview it, you need the reverse remap, which this node doesn't provide - you'd use the pack's Remap Image Range node (a different node, with explicit min/max and a clamp option) to bring it back. Pairing those two is the intended workflow: this node is the cheap one-direction conversion for the common case, Remap Image Range is the general tool.
A caveat about saving
Don't wire this into a Save Image node and expect a normal picture. Values below zero hit the saver's clip and come back black; you'll get a high-contrast, half-black result. If you're debugging and you want to look at the normalized tensor, preview it before the remap, not after - or push it back through Remap Image Range with min=0, max=1 for a sanity check.
Install
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/aining2022/ComfyUI_Swwan.git
cd ComfyUI_Swwan
python -m pip install -r requirements.txt
Windows portable:
.\python_embeded\python.exe -m pip install .\ComfyUI\custom_nodes\ComfyUI_Swwan\requirements.txt
Restart ComfyUI, hard-refresh the browser, search Swwan. It's under Swwan/Advanced/Image, and it needs nothing beyond torch, which your ComfyUI already has - no model downloads, no extra wheels, no GPU work worth measuring.
One last thing: this node, like most of the pack's image utilities, is a KJNodes-lineage algorithm under the hood, re-registered under a Swwan ID as part of the pack's 1.0.0 namespace split. That split is why you can install this pack instead of KJNodes for these utilities, and it's also why an old workflow referencing the original ID needs the repo's migration script (python scripts/migrate_workflow.py old.json --dry-run) rather than just working. The pack registers no conflicting aliases on purpose.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |