Nodes/comfyui-DF-ResizeImage/comfyui-DF-ResizeImage
ComfyUI Node

comfyui-DF-ResizeImage

The resize node that stops your image from ever being off-grid again

By Hu-Tao66·Created 5 months ago·Updated 5 months ago· 1
comfyui-DF-ResizeImage
  • image
  • image
  • width
  • height
mode
interpolation
multiple_of16
rounding
long_side1536
short_side1024
scale_factor1.00

Resizing an image sounds like the most boring thing you can do in ComfyUI, right up until a model silently spits out a mangled picture because your reference was 1023×1025 instead of a clean 1024×1024. comfyui-DF-ResizeImage is the fix for that class of problem: it resizes an image and snaps both final dimensions to a multiple you choose, so whatever you feed it lands on the grid your model actually likes.

Why the grid matters: every architecture was trained at a native resolution, and most of them degrade when you wander off it - SD 1.5 at 512, SDXL at its handful of trained ratios, Flux happy above 1024 but picky about divisibility (the KB's resolution notes flag Flux at "must be divisible by 64"). It's the classic stopgap for prepping a ControlNet reference, an img2img source, or a detailer crop that's a few pixels shy of where the model wants to be.

How it works

Under the hood it's just torch.nn.functional.interpolate on your image tensor, wrapped in two smart bits. First, a snap_to_multiple step: the target dimension is rounded to the nearest (or floor/ceil) multiple of multiple_of. Second, for the aspect-ratio modes it recomputes the other side from the ratio, so you get "long side = 1536, other side as close as the grid allows" instead of a stretched mess. Bilinear and bicubic get align_corners=False plus antialias=True, which means downscales look smooth rather than shimmering, and the output is clamped back to 0–1. No model files, no API, no dependencies beyond what ComfyUI already ships.

The inputs and outputs that matter

You'll touch four things. mode picks the strategy: long_side and short_side resize by one edge while keeping the ratio, scale_factor multiplies both dimensions, and long_and_short sets width and height directly. multiple_of (default 16) is the grid, rounding is nearest/floor/ceil, and interpolation is bicubic/bilinear/area/nearest.

It returns the resized image plus the final width and height as INTs - so you can wire the actual output size into a text box or latent node and never have to guess what it landed on.

Install

Easiest via ComfyUI Manager: search "comfyui-DF-ResizeImage" and install. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/Hu-Tao66/comfyui-DF-ResizeImage

Then restart ComfyUI. There's no requirements.txt and nothing to download - it's a single Python file.

Gotchas worth knowing

The one that'll trip you up: long_and_short does not preserve aspect ratio. It just slaps both values onto the image, so a 1536-long / 1024-short request on a square source will distort it. Use it only when you want an exact box, not a ratio.

Second, floor and ceil rounding can undershoot or overshoot your target - a 1536 request with ceil and a 64 grid gives you 1536, but a slightly-off ratio side can jump a whole grid step. If you want "as close as possible," nearest is the sane default. And yes, multiple_of goes up to 512; if you're targeting Flux, set it to 64 yourself and let the node keep the rest honest.

Categoryimage/resize

Inputs (8)

NameTypeDefaultDescription
imageIMAGE
modeCOMBO4 options: long_side, short_side, scale_factor, long_and_short
interpolationCOMBO4 options: bicubic, bilinear, area, nearest
multiple_ofINT161–512
roundingCOMBO3 options: nearest, floor, ceil
long_sideINT15361–32768
short_sideINT10241–32768
scale_factorFLOAT1.000.01–64

Outputs (3)

NameTypeDescription
imageIMAGE
widthINT
heightINT