Image Scale By Short Side Factor @zn123
Small images get big, big ones pass through
- image
- scaled_image
- width
- height
- scale_factor
- scale_info
Here's a problem the basic upscalers can't solve: your batch is full of images at completely different resolutions, and you want every one of them to end up usefully sized without babysitting each one. Image Scale By Short Side Factor @zn123 answers with tiers. Look at its short side, pick a band, apply that band's multiplier. It's the one node in this pack that actually thinks.
The mechanism
The node measures the image's short side and picks one of three scaling factors based on two thresholds:
- short side below
threshold1→ multiply byscale_factor1 - short side between
threshold1andthreshold2→ multiply byscale_factor2 - short side at or above
threshold2→ multiply byscale_factor3
The defaults spell it out: short side under 512 → 4x, 512–1024 → 2x, over 1024 → 1x (untouched). That's the entire use case in one line: tiny thumbnails get blown up to something usable, middling images get a boost, and anything already decent sails through untouched. It's the pixel-space equivalent of "normalize my training/preprocessing batch" and it saves you a stack of condition nodes.
The inputs, for when you tune it:
threshold1/threshold2- INTs, the band boundaries (defaults 512 and 1024)scale_factor1/scale_factor2/scale_factor3- FLOATs, defaults 4.0 / 2.0 / 1.0only_upscale- BOOLEAN, default true: clamps any factor below 1.0 up to 1.0, so a band that would shrink your image just passes it throughupscale_method- the usual five (defaultbicubic)
The output side is where it gets interesting. Besides scaled_image (IMAGE) you get width and height (INT), a scale_factor (FLOAT) telling you what multiplier was applied, and scale_info (STRING) - a human-readable summary like Original: 400×300, Short side: 300px, Scale: 4.0x, New: 1600×1200, short side < 512px. Wire scale_info into a text display node and the graph tells you exactly what it decided. That's a genuinely nice touch.
This node is an output node
Note the small detail in its definition: it's marked as an output node, so it can sit at the end of a graph and it prints that summary text into ComfyUI's output area when it runs. You get a live readout of what each image was scaled to - invaluable when you're processing a mixed batch and wondering why one file came out 4x bigger than its neighbor.
Installing it
Same pack, same install as everything else here:
- ComfyUI Manager - search "ComfyUI-image-processor-zn123", install, restart.
- Manual - from
ComfyUI/custom_nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/zn123/ComfyUI-image-processor-zn123
Restart, find it under image/processor. No models, no downloads; requirements are just torch/numpy/Pillow, which ComfyUI already has.
Gotchas
- Keep
threshold2abovethreshold1. The bands are checked in order (if short < threshold1 … elif short < threshold2), so if you set them backwards or equal, the middle band silently never fires. No error, just a dead tier. - Mind the pixel math. 4x on the short side is 16x the pixels - a 400x300 image becomes 1600x1200, and a 64px source would hit 256px on a side but still be tiny in real terms. Interpolation can't invent detail; this node multiplies pixels, it doesn't restore. For genuinely soft sources, run a real detail upscaler first.
only_upscaledefaults to true, so bands configured below 1.0 become pass-through, not downscaling. Expect that, or flip it.
Set your bands, forget it, let the batch normalize itself. This is the node you install the pack for.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| upscale_method | COMBO | bicubic | 5 options: nearest, bilinear, bicubic, area, lanczos |
| threshold1 | INT | 51264–2048 | — |
| threshold2 | INT | 102464–4096 | — |
| scale_factor1 | FLOAT | 4.00.1–10 | — |
| scale_factor2 | FLOAT | 2.00.1–10 | — |
| scale_factor3 | FLOAT | 1.00.1–10 | — |
| only_upscale | BOOLEAN | true | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| scaled_image | IMAGE | — |
| width | INT | — |
| height | INT | — |
| scale_factor | FLOAT | — |
| scale_info | STRING | — |