๐บ Resize Image v2
The resize node that can pad, crop, or blur-fill โ and survives big batches
- image
- mask
- IMAGE
- width
- height
- mask
Every video or batch workflow eventually hits the same wall: your sampler spat out 121 frames at some awkward resolution, and the next node in the chain demands a specific size, or a multiple of 16, or a uniform canvas. Core ComfyUI can resize, but it makes you juggle three different nodes for "fit inside a box", "crop to fill", and "pad to exact size". Nilor's Resize Image v2 does all of it in one node, and it does the part core ComfyUI quietly refuses to do well: handling the whole batch without blowing up your VRAM.
What it actually does
Feed it an image and a target width and height (both default 512), pick an upscale_method - nearest-exact, bilinear, area, bicubic, or lanczos - and a keep_proportion mode, and it returns the resized IMAGE plus the real width and height it landed on. The outputs matter more than they look: if you set one dimension to 0, the node infers it from the other to preserve aspect ratio, so the width/height outputs are the only way to know what you actually got.
The keep_proportion dropdown is where the value is. It's not a boolean despite the name - it's a mode list:
- stretch - default, just squashes to the exact box.
- resize - scales to fit inside the box, keeps aspect, no padding.
- pad, pad_edge, pad_edge_pixel - fit, then fill the leftover with a solid
pad_color(default0, 0, 0), the image's edge pixels, or a single stretched edge pixel. - pillarbox_blur - fit, then fill the bars with a blurred copy of the image. This is the "cinematic letterbox" look people usually build with three extra nodes.
- crop - zoom in and crop so the box is filled edge to edge.
Add crop_position (center/top/bottom/left/right) and divisible_by (default 2) to round the output down to a multiple, and you can satisfy almost any downstream constraint in one shot. It also takes an optional mask, which gets resized and padded in lockstep - handy if you're carrying a region mask through to an inpainting step.
The memory trick
The headline feature is per_batch, which defaults to 16. Instead of upscaling all 121 frames in one giant tensor, the node slices the batch into sub-batches of 16, processes each, and concatenates. On device: gpu that's the difference between a smooth run and a CUDA out-of-memory crash when you're pushing 512โ2048 on a batch. Set it to 0 to disable batching. One real gotcha: lanczos is not supported on the GPU - the node raises an error rather than silently swapping, so if you hit that, switch device to cpu or drop to bicubic.
Install and dependencies
Install via ComfyUI Manager (search "Nilor Nodes") or:
cd ComfyUI/custom_nodes
git clone https://github.com/nilor-corp/nilor-nodes
cd nilor-nodes && pip install -r requirements.txt
Restart ComfyUI. Two dependencies to know about. First, this node's padding calls ImagePadKJ from KJNodes (comfyui-kjnodes) - the pack lists it as a prerequisite, so install it or pad/pillarbox_blur modes will fail at runtime. Second, the pack's own requirements.txt is a kitchen sink (boto3, opencv, openexr, imageio-ffmpeg...) that mostly exists for Nilor's streaming/worker infrastructure you'll never touch; the resize node itself only needs torch, numpy, and KJNodes.
Where it bites
The usual complaint is the "Lanczos is not supported on the GPU" error, which is by design. The subtler one: divisible_by rounds down, so a 513 target becomes 512, and if you also requested padding, the pad amounts get recomputed to stay divisible - the returned width/height are the ground truth, always trust those over your widget values. If nothing resizes at all, check you're not feeding it a single image when you expect batch behavior; per-batch kicks in only when the batch exceeds the limit. It's not a model, so there's no upscaling detail here - this is the "more pixels / reformat" job, not a SeedVR2-style restoration, and it makes no secret of it.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | โ | |
| width | INT | 5120โ9007199254740991 | โ |
| height | INT | 5120โ9007199254740991 | โ |
| upscale_method | COMBO | 5 options: nearest-exact, bilinear, area, bicubic, lanczos | |
| keep_proportion | COMBO | false | 7 options: stretch, resize, pad, pad_edge, pad_edge_pixel, crop, +1 |
| pad_color | STRING | 0, 0, 0 | โ |
| crop_position | COMBO | center | 5 options: center, top, bottom, left, right |
| divisible_by | INT | 20โ512 | โ |
| maskopt | MASK | โ | |
| deviceopt | COMBO | 2 options: cpu, gpu | |
| per_batchopt | INT | 160โ4096 | Process images in sub-batches. 0 disables. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | โ |
| width | INT | โ |
| height | INT | โ |
| mask | MASK | โ |