Smart Image Resize
Make any image fit a resolution band without doing the math yourself
- image
- image_reference
- upscale_model
- image
- width
- height
Smart Image Resize is the flagship node of Zar4X's small ComfyUI-Image-Resizing pack, and the one I'd install the pack for. Most resize nodes make you be precise; this one invites you to be lazy. You hand it a minimum and a maximum resolution, and it lands the image inside that band - downscaling if it's too big, upscaling until the short side clears the floor, optionally padding to a standard ratio. It's the "I just need this to be Comfy-appropriate" button.
How it actually decides
The logic is straightforward once you know the shape of it. It reads your image's dimensions, then:
- If the longest side exceeds
max_resolution, it scales down to fit. - If the shortest side is below
min_resolution, it upscales byupscale_factorin a loop (up to 10 iterations) until the short side clears the floor. - If it's already inside the band, it leaves the image alone.
The interesting bit is what the code calls "scenario 3": extreme aspect ratios where the long side would blow past the max before the short side reaches the min (think a 400×4000 panorama). Upscaling that to 1024 on the short side would give you a 10,240px-wide monster. So it checks an area threshold (min_resolution × max_resolution) plus a sum threshold and a 1.5× long-side tolerance, and stops when it decides you've got enough pixels. That guard is the whole reason this node is safe to leave on autopilot.
The inputs that matter
You'll touch five things:
- min_resolution (default 1024) and max_resolution (default 1536) - the band. Defaults are SDXL-ish; for Flux you'll want min 1024 / max 2048+, since Flux really wants dimensions divisible by 64 anyway.
- upscale_factor (default 1.5) - how aggressive each upscale step is. Minimum is 1.1, so you can't set 1.0 for "don't upscale"; that's what min_resolution alone is for.
- upscale_method -
lanczosis the usual quality pick;areais a decent downscale choice. Defaults are fine for most people. - standard_ratio (off by default) - when on, pads with black to the closest of 3:4, 4:3, 1:1, 16:9 or 9:16, keeping dimensions inside your band.
Two optional inputs are worth knowing. image_reference pads your image with black to match another image's aspect ratio without resizing it - handy for matching a batch of assets to a template. upscale_model takes a real upscale model (an ESRGAN/Real-ESRGAN class model) and uses it via tiled upscaling instead of plain interpolation, then finishes with a resize to your exact factor. Plugging one in trades speed for noticeably better detail, the same trade you're already making when you pick a model upscaler over Lanczos elsewhere.
Outputs are image, plus width and height as integers - nice if you want to log or compute with the result.
Gotchas
It never crops, only scales and pads, and padding is pure black. That's a letterbox, not a mistake - if you want to trim it back later, the same pack's RemovePadding node undoes it in one step. Also, this node is chatty: it prints a progress log to the console on every single run. Harmless, mildly annoying, ignore it.
Install
It's a tiny pack with no model files and no exotic dependencies - just torch, Pillow, numpy and OpenCV, which you almost certainly already have. Install via ComfyUI Manager (search "ComfyUI-Image-Resizing") or:
cd ComfyUI/custom_nodes
git clone https://github.com/Zar4X/ComfyUI-Image-Resizing
Restart ComfyUI and it'll be under Image Resizing in the node menu.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| min_resolution | INT | 102464–8192 | — |
| max_resolution | INT | 153664–8192 | — |
| upscale_factor | FLOAT | 1.51–4 | — |
| upscale_method | COMBO | 5 options: area, lanczos, bilinear, nearest-exact, bicubic | |
| standard_ratio | BOOLEAN | false | — |
| image_referenceopt | IMAGE | — | |
| upscale_modelopt | UPSCALE_MODEL | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |