ComfyUI Node

Max

The blend mode everyone's missing — elementwise maximum of two images

By CoiiChan·Created about a year ago·Updated about a year ago· 2
Max
  • imga
  • imgb
  • IMAGE
formularesult = np.maximum(imga, imgb)

The README of this pack literally opens with a complaint: it's surprisingly hard to find a Max(image a, image b) operation in ComfyUI's stock node set. Everyone reaches for screen, overlay, and multiply - but sometimes what you want is just "keep the brighter pixel at every position." This node is that. It's the "lighten" blend mode, the one your image editor has had for thirty years and your diffusion workflow somehow lacks.

Why would you want the per-pixel maximum? The classic use is combining two mask-like images without averaging them down. Say you have a mask from a depth map and a mask from an edge pass. Add them and overlapping bright regions blow past 1.0; average them and both get fainter. max keeps both masks fully intact - the result is bright wherever either source was bright. Same logic applies to keeping specular highlights from one pass and shadows from another: maximum is a boolean OR for images.

How it works

Like every basic node in this pack, Max is a pre-filled CustomScript-NumPy formula. The formula is literally:

result = np.maximum(imga, imgb)

np.maximum compares element-by-element and keeps the larger value. Because it works per-channel, the "brighter" test is really per color component - a pixel that's brighter in red but darker in blue ends up with the red from one image and the blue from the other. That's standard for this family of blends, and it's usually what you want.

Inputs and outputs

  • formula - the script above, pre-filled. Yes, it's a required input on a "simple" node. That's the pack's design: every basic node is an editable formula with the unused parameters hidden. Change it if you want; the default is fine.
  • imga - the reference image. Defines output resolution (512×512 if left unconnected).
  • imgb - the second image. Missing = treated as an all-zero array, so the output just becomes imga with negatives clamped away.

One IMAGE output.

Install

ComfyUI Manager → search "FuncAsTexture", or:

cd ComfyUI/custom_nodes
git clone https://github.com/CoiiChan/ComfyUI-FuncAsTexture-CoiiNode
# restart ComfyUI

No models, no requirements.txt - pure NumPy/PyTorch/Pillow. Category: FunctionAsTexture.

Notes

  • Inputs must match resolution. If imga and imgb differ in size, numpy throws - this is the pack's number-one README warning and it applies to every two-image node here.
  • The output isn't clamped, but a max of values that are already 0–1 stays in 0–1, so you're safe with this one specifically.
  • Min is the sibling - np.minimum gives you the "darken" blend, useful for cutting a bright region out of a composite. If you need Max's opposite, that node is in the same pack.

If you've been faking "lighten" with a screen blend and wondering why the colors wash out, this is the honest version. It's the node the pack was partly born to provide.

CategoryFunctionAsTexture

Inputs (3)

NameTypeDefaultDescription
formulaSTRINGresult = np.maximum(imga, imgb)
imgaoptIMAGEOptional ,Reference size ,Default =(1,512,512,3)
imgboptIMAGEOptional

Outputs (1)

NameTypeDescription
IMAGEIMAGE