Nodes/ComfyUI-UniversalToolkit/Resize Image ver KJ (UTK)
ComfyUI Node

Resize Image ver KJ (UTK)

The KJ v2-style resize node that covers every fit mode, mask included

By whmc76·Created about a year ago·Updated 2 months ago· 72
Resize Image ver KJ (UTK)
  • image
  • mask
  • IMAGE
  • width
  • height
  • mask
width512
height512
upscale_method
keep_proportionresize
pad_color0, 0, 0
crop_positioncenter
divisible_by2
devicecpu

There's a resize node for every occasion, and then there's Resize Image ver KJ (UTK) - the one from ComfyUI-UniversalToolkit that tried to cover every occasion. It's explicitly modeled on kijai's KJNodes Image Resize v2 (the pack credits kijai's nodes as reference), and it bundles the full set of fit modes in a single dropdown. Stretch, resize, pad, pad_edge, pad_edge_pixel, crop, pillarbox_blur, total_pixels - plus crop_position, a divisible_by snap, and a mask that resizes in lockstep. If you've used KJNodes, you know exactly what this is; if you haven't, it's the most capable single resize node in this pack.

How it works

You give it a target width and height, then keep_proportion decides what "fitting" means:

  • resize - proportional scale only, no fill. Output may be smaller than the target on one axis. v1.4.7 made this distinction explicit after resize and pad were confusingly identical.
  • pad / pad_edge / pad_edge_pixel - scale to fit, fill the rest with pad_color (default "0, 0, 0" = black).
  • stretch - force exact dimensions, distortion allowed.
  • crop - scale to cover and crop the overflow.
  • pillarbox_blur - fill the leftover with a blurred, dimmed copy of the image. Cinema letterbox.
  • total_pixels - interpret width×height as a total pixel budget and compute dimensions that preserve aspect ratio.

crop_position (a string: center/top/bottom/left/right) anchors both crop and pad placement. divisible_by (default 2) snaps the result to a multiple, which is how you keep latent-friendly sizes like 8 or 16 without thinking about it. upscale_method gives you the PyTorch sampler set - nearest-exact, bilinear, area, bicubic, lanczos - and there's a device toggle (cpu/gpu) for the torch ops.

The optional mask input is the standout for inpainting pipelines: the mask gets resized with the same fit logic, so a crop or pad on the image is mirrored exactly on the mask. No separate mask-resize node, no misalignment.

Inputs and outputs that matter

  • width / height - the target.
  • keep_proportion - the fit mode; this is 90% of the node's personality.
  • divisible_by - snap factor, default 2.
  • mask - optional, resized in lockstep.

Outputs: IMAGE, width (actual), height (actual), and mask.

Install and gotchas

Install via ComfyUI Manager (search "ComfyUI-UniversalToolkit") or:

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

Restart ComfyUI. No models, no keys.

The gotchas are the same ones the pack's changelog had to fix, so you don't have to relive them: resize does not fill to the target - if you need exact output dimensions, use pad. And pad_color here is a free-text string ("0, 0, 0"), not the preset list the pack uses in its other resize nodes - a mismatch worth knowing before you type "black" and get a parse error. One more: this is interpolation, the "more pixels" job, not a detail-adding upscaler, so don't expect it to invent texture on a big upscale.

CategoryUniversalToolkit/Image

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
widthINT5120–16384
heightINT5120–16384
upscale_methodCOMBO5 options: nearest-exact, bilinear, area, bicubic, lanczos
keep_proportionCOMBOresize8 options: stretch, resize, pad, pad_edge, pad_edge_pixel, crop, +2
pad_colorSTRING0, 0, 0
crop_positionSTRINGcenter
divisible_byINT20–512
maskoptMASK
deviceoptCOMBOcpu2 options: cpu, gpu

Outputs (4)

NameTypeDescription
IMAGEIMAGE
widthINT
heightINT
maskMASK