Nodes/KJNodes for ComfyUI/Resize Image v2
ComfyUI Node Runs on cloud

Resize Image v2

The resize node that actually handles aspect ratio

By kijai·Created 3 years ago·Updated a day ago· 3,011
Resize Image v2
  • image
  • mask
  • IMAGE
  • width
  • height
  • mask
width512
height512
upscale_method
keep_proportionfalse
pad_color0, 0, 0
crop_positioncenter
divisible_by2
device

Core ComfyUI can resize an image, but the built-in nodes make you choose between "scale to exact WxH and distort it" or "scale by a factor and hope the result is legal." Resize Image v2 is the node people reach for when they want a target resolution and control over what happens to the aspect ratio and dimensions a diffusion model won't choke on - all in one box. It's the workhorse resize in a lot of Wan and Flux workflows for exactly that reason: it's the node you drop in front of a model to make an arbitrary input photo fit cleanly before it ever hits the sampler.

First, set expectations. This is a geometric resize - plain pixel interpolation. It makes an image bigger or smaller; it does not invent detail. If your goal is to recover a soft or low-res image, that's a job for a model upscaler (ESRGAN, SUPIR, SeedVR2), not this. Think of Resize Image v2 as the tool for reshaping and fitting, and a model upscaler as the tool for adding pixels that weren't there. The two often sit in the same graph doing different jobs.

How it works and the inputs that matter

You give it an image, a target width and height, and then two settings decide everything:

  • keep_proportion - this is the one that separates it from the stock node. Left stretching, it squashes the image to the exact WxH you asked for (fine for square-to-square, ugly for anything else). Set it to a proportion-preserving mode instead: resize fits by the longest side, pad / pad_edge fills the leftover space (with pad_color, default black) so nothing gets cut, crop trims the overflow to fill the frame instead, and total_pixels targets a pixel budget rather than fixed dimensions. Pick based on whether you can tolerate bars (pad) or lost edges (crop).
  • upscale_method - the interpolation filter. lanczos is the quality default for both up- and down-scaling and is a perfectly respectable choice on its own; bicubic/bilinear/area/nearest-exact are the classic tradeoffs; nvidia_rtx_vsr is NVIDIA's RTX Video Super Resolution path, real-time and hardware-accelerated but still interpolation-class (closer to Lanczos than to a diffusion upscaler - it cleans and enlarges, it won't add pores or lashes).

The other input worth knowing is divisible_by (default 2). Diffusion models want dimensions that divide cleanly - the VAE downsamples by 8, and plenty of workflows want 16 or 64 - and mismatched sizes throw shape errors deep in the graph where they're annoying to trace. Set divisible_by and the node rounds the output to a legal size for you. That one setting quietly prevents a whole category of "tensor size mismatch" crashes.

crop_position (center/top/bottom/left/right) only matters when you're in a crop mode; pad_color only when padding. There's an optional device (cpu/gpu) if you want to force where the resize runs.

Outputs - and the underrated ones

Four come out: IMAGE, plus width and height as INT values, plus mask. The width/height integers are the sleeper feature - wire them into your latent or a downstream node so the rest of the graph matches whatever this node actually produced, instead of you hardcoding numbers that drift out of sync. And the optional mask input/output means a mask gets resized in lockstep with the image - same crop, same pad - which is exactly what you need for inpainting, where the mask and image must stay pixel-aligned.

Installing it

It ships in KJNodes, Kijai's big utility pack. Easiest path is ComfyUI Manager: search "KJNodes for ComfyUI", install, restart. Manual is fine too:

cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-KJNodes
pip install -r ComfyUI-KJNodes/requirements.txt

Restart ComfyUI. No model files, no heavy dependencies - the pack is deliberately light.

Where people get burned

The big one is expecting keep_proportion to default to something sane. If your output looks squashed or stretched, you left it on the stretching behavior - switch to resize, pad, or crop. Second: don't expect this node to sharpen anything. Upscaling a small image here just gives you a bigger blurry image; if there's no detail in the source, interpolation can't manufacture it, and that's when you hand off to a real upscale model. And if you're feeding the result into a sampler and hitting shape errors, check divisible_by matches what your model wants (8 is the safe floor) before you go hunting anywhere else.

CategoryKJNodes/image

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
widthINT5120–16384
heightINT5120–16384
upscale_methodCOMBO6 options: nearest-exact, bilinear, area, bicubic, lanczos, nvidia_rtx_vsr
keep_proportionCOMBOfalse8 options: stretch, resize, pad, pad_edge, pad_edge_pixel, crop, +2
pad_colorSTRING0, 0, 0Color to use for padding.
crop_positionCOMBOcenter5 options: center, top, bottom, left, right
divisible_byINT20–512
maskoptMASK
deviceoptCOMBO2 options: cpu, gpu

Outputs (4)

NameTypeDescription
IMAGEIMAGE
widthINT
heightINT
maskMASK