Nodes/ComfyUI-Image-Resizing/Smart Image Resize
ComfyUI Node

Smart Image Resize

Make any image fit a resolution band without doing the math yourself

By Zar4X·Created about a year ago·Updated 14 days ago· 5
Smart Image Resize
  • image
  • image_reference
  • upscale_model
  • image
  • width
  • height
min_resolution1024
max_resolution1536
upscale_factor1.5
upscale_method
standard_ratiofalse

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 by upscale_factor in 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 - lanczos is the usual quality pick; area is 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.

CategoryImage Resizing

Inputs (8)

NameTypeDefaultDescription
imageIMAGE
min_resolutionINT102464–8192
max_resolutionINT153664–8192
upscale_factorFLOAT1.51–4
upscale_methodCOMBO5 options: area, lanczos, bilinear, nearest-exact, bicubic
standard_ratioBOOLEANfalse
image_referenceoptIMAGE
upscale_modeloptUPSCALE_MODEL

Outputs (3)

NameTypeDescription
imageIMAGE
widthINT
heightINT