Nodes/ComfyUI_Swwan/Resize Image v2 (KJ Alternative)
ComfyUI Node

Resize Image v2 (KJ Alternative)

The resize node that finally settles crop-vs-pad-vs-blur

By aining2022·Created 10 months ago·Updated 18 days ago· 33
Resize Image v2 (KJ Alternative)
  • image
  • mask
  • IMAGE
  • width
  • height
  • mask
width512
height512
upscale_method
keep_proportionfalse
pad_color0, 0, 0
crop_positioncenter
divisible_by2
device

Every video workflow ends in the same argument. Your model wants 1344×768, your source image is 3:2, and you have to decide whether to crop the photo, stretch it, or letterbox it - and you'd rather make that call in one node than three. That's what Resize Image v2 (KJ Alternative) is for.

It's a direct port of kijai's resize node from KJNodes, re-registered under its own class name so it can sit in the same graph as KJNodes without a name collision. Same behavior, no fighting. The one thing that's genuinely new here is an optional NVIDIA RTX VSR upscale path, which gets a paragraph of its own below.

What it actually does

Feed it an IMAGE, give it a target width and height, and it resizes. The keep_proportion dropdown is where the real work happens - it's not a checkbox, it's a menu of eight strategies. Most days you only care about three of them:

  • stretch - force it into the box, ignore the aspect ratio. Distortion, but predictable.
  • crop - scale to fit, then crop the overhang. Pair it with crop_position (center/top/bottom/left/right) so you keep the part of the frame you actually care about.
  • pad and pillarbox_blur - fit the whole image and fill the leftover space with a solid pad_color (default "0, 0, 0") or a blurred copy of the image itself. The blur one is what makes a video look intentional instead of banded.

resize and total_pixels are the oddballs: resize keeps the aspect ratio by the highest dimension, and total_pixels targets a pixel budget rather than exact dimensions. Niche, but they're why people port this node into their own packs.

The inputs that matter

  • upscale_method - nearest-exact, bilinear, area, bicubic, lanczos, and nvidia_rtx_vsr. For real resizing, lanczos or bicubic are the honest picks; the others exist so you can match how something was produced.
  • width / height (defaults 512, up to 16384) - the target box.
  • divisible_by (default 2) - this is the one that saves you an evening of "latent dimension not divisible" errors. Set it to 16 or 32 for most video models.
  • Optional mask input and a device toggle (cpu/gpu) for when you're batching on a card that's already full.

Outputs: the resized IMAGE, the actual output width and height as INTs (handy to wire forward into other nodes), and the resized mask.

The RTX VSR option

nvidia_rtx_vsr uses NVIDIA's video super-resolution path, lazily loading the optional nvvfx / nvidia-vfx runtime on compatible CUDA NVIDIA GPUs and snapping output to the nearest multiple of 8. It sits on the "more pixels, want it now" rung of the upscaling ladder - closer to a very good Lanczos than to a generative restorer, and the community reads its output as more natural than diffusion upscalers on already-clean sources. It will not add eyelashes, so don't reach for it to repair a genuinely soft image. That's a different job and a different node.

Install & gotchas

ComfyUI Manager, search "ComfyUI_Swwan", or:

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

then restart ComfyUI. The pack's requirements are light - torch, numpy, opencv, scipy, spandrel, color-matcher - nothing model-download sized. The VSR path is the only heavyweight, and it's optional. If nvidia-vfx refuses to build from requirements, the known fix is:

python -m pip install -U --no-build-isolation nvidia-vfx --index-url https://pypi.nvidia.com

And one reminder: the VSR path aligns output to multiples of 8. Set divisible_by to match instead of fighting it, and the whole thing behaves.

CategorySwwan/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