ComfyUI Node Runs on cloud

IMG_scaler

Run any math expression on every pixel β€” brightness, contrast, weird curves

By edenartlabΒ·Created 3 years agoΒ·Updated 6 months agoΒ· 119
IMG_scaler
  • image
  • IMAGE
β—„math_stringβ–Ί

IMG_scaler is a pocket calculator for pixels. You type a math expression, and it applies that expression to every pixel value in the image. 1-x inverts it. x**0.5 brightens the shadows. x*2 blows out the highlights (and gets clamped). It's not an AI node and it's not a "scaler" in the upscaling sense - the name is a small lie; think "apply a math function per pixel."

It's part of eden_comfy_pipelines, Eden.art's 70+ node suite, under Eden 🌱/Image.

What you set

  • image - the input image tensor.
  • math_string - the expression, written in terms of x, which stands for each pixel's value. Pixels are 0–1 floats internally, so expressions live in that range.

One output, IMAGE, the transformed result.

What expressions actually work

The safe-eval sandbox in the source allows a short whitelist: numpy's sin, cos, and exp, plus basic arithmetic and Python operators. So:

  • 1 - x - invert (negative).
  • x ** 0.5 - gamma-ish brightening.
  • x ** 2 - darkening / contrast punch.
  • sin(x * 3.14) - a wavy curve that will do genuinely weird things, if that's what you're after.
  • x + 0.1 - lift everything 10%.

Two constraints that will bite you. First, the variable must be x - type pixel and you get a NameError. Second, the whitelist is deliberately tiny: no log, no sqrt (write x**0.5), no abs, no Python if. If your expression references anything outside the whitelist, the node errors out and you'll see the exception in the console. Think of it as a curated function set, not a full scripting environment.

The output is clamped to 0–1, which is what you want (pixels live in that range) but worth knowing if you expected x*2 to preserve values above 1 - it won't, everything above 1 just becomes white.

Where it's genuinely useful

  • Quick contrast/gamma tweaks without dropping in a whole color-adjustment node - x**0.5 vs x**2 covers the common curve shapes.
  • Inversion for masks or tests: 1-x on a mask flips it cleanly.
  • Experiments: if you've ever wanted to see what x * sin(x*6.28) does to an image, this is the cheapest way to find out.

For normal photo editing you'll usually reach for a proper image-adjustment node instead - this one is for when you want a specific curve and none of the presets do it. It's also a great teaching tool: any function you can type, you can watch applied to an image.

Installing it

Standard pack install - ComfyUI Manager (search "eden"), or:

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

Restart ComfyUI. Needs numpy (in the pack requirements) - no models, no keys, CPU is fine. Type an expression, run, enjoy the weirdness.

CategoryEden 🌱/Image

Inputs (2)

NameTypeDefaultDescription
imageIMAGEβ€”
math_stringSTRINGβ€”

Outputs (1)

NameTypeDescription
IMAGEIMAGEβ€”