Resize Image (Swwan)
The resize node that finally settles crop-vs-pad-vs-blur
- image
- mask
- fill_color
- IMAGE
- width
- height
- mask
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 withcrop_position(center/top/bottom/left/right) so you keep the part of the frame you actually care about.padandpillarbox_blur- fit the whole image and fill the leftover space with a solidpad_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, andnvidia_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
maskinput and adevicetoggle (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.
Inputs (27)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 5120–16384 | — |
| height | INT | 5120–16384 | — |
| upscale_method | COMBO | 6 options: nearest-exact, bilinear, area, bicubic, lanczos, nvidia_rtx_vsr | |
| keep_proportion | COMBO | stretch | 8 options: stretch, resize, pad, pad_edge, pad_edge_pixel, crop, +2 |
| pad_color | STRING | 0, 0, 0 | Color to use for padding. |
| crop_position | COMBO | center | 5 options: center, top, bottom, left, right |
| divisible_by | INT | 20–512 | — |
| maskopt | MASK | — | |
| deviceopt | COMBO | 2 options: cpu, gpu | |
| resize_modeopt | COMBO | standard | 4 options: standard, edit_size, aspect_ratio, essentials |
| size_ruleopt | COMBO | 按长边等比例 | 3 options: 按长边等比例, 按短边等比例, 自定义宽高 |
| edge_lengthopt | INT | 102464–100000 | — |
| execute_conditionopt | COMBO | 总是 | 3 options: 总是, 最长边大于时, 最小边小于时 |
| edit_fitopt | COMBO | 裁剪 | 6 options: 拉伸, 裁剪, 填充_自定颜色, 填充_边框颜色, 填充_边缘像素, 总像素_等比例 |
| fill_coloropt | COLORCODE | #364254 | — |
| aspect_ratioopt | COMBO | original | 9 options: original, custom, 1:1, 3:2, 4:3, 16:9, +3 |
| proportional_widthopt | INT | 1 | — |
| proportional_heightopt | INT | 1 | — |
| aspect_fitopt | COMBO | letterbox | 3 options: letterbox, crop, fill |
| aspect_methodopt | COMBO | lanczos | 6 options: lanczos, bicubic, hamming, bilinear, box, nearest |
| aspect_roundopt | COMBO | 8 | 8 options: 8, 16, 32, 64, 128, 256, +2 |
| aspect_scale_sideopt | COMBO | longest | 6 options: None, longest, shortest, width, height, total_pixel(kilo pixel) |
| aspect_lengthopt | INT | 1024 | — |
| essentials_methodopt | COMBO | 4 options: stretch, keep proportion, fill / crop, pad | |
| essentials_conditionopt | COMBO | 5 options: always, downscale if bigger, upscale if smaller, if bigger area, if smaller area | |
| essentials_interpolationopt | COMBO | 6 options: nearest, bilinear, bicubic, area, nearest-exact, lanczos |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| width | INT | — |
| height | INT | — |
| mask | MASK | — |