Resize Image (KJ/SET)
One resize node that stretches, pads, crops, or blurs — the KJ/SET workhorse
- image
- mask
- get_image_size
- IMAGE
- width
- height
- mask
If you've used ComfyUI for more than a week you've hit the moment where an image needs to be exactly 1024×1024 and it isn't, and the fix has to survive an aspect ratio you don't want to wreck. That's this node. It's a port of Kijai's ImageResizeKJ from KJNodes with a few genuine improvements, which is why it's labeled KJ/SET - the "KJ" is a real attribution, not marketing. The author (set-soft, who maintains the Image Misc pack) kept the KJNodes logic and added flexible color parsing, reference-image sizing, sub-batching, and transparency control on the padding.
How it works
The keep_proportion dropdown is the heart of it, and it's seven modes pretending to be one node:
stretch- force the exact width/height, aspect ratio be damned. Default.resize- fit inside the target keeping aspect; one dimension may come out short.pad/pad_edge/pad_edge_pixel- fit keeping aspect, then fill the leftover with a solid color, the average edge color, or repeated edge pixels.crop- fill the target keeping aspect by cutting off the edges;crop_positionpicks where.pillarbox_blur- fit the image and fill the bars with a blurred, desaturated, dimmed version of itself.
Under the hood it uses ComfyUI's common_upscale, so upscale_method gives you the usual five interpolations (nearest-exact, bilinear, area, bicubic, lanczos). Two details matter more than they look: divisible_by snaps the final size to a multiple (default 2) - set it to 8 or 16 when you're feeding a VAE that demands it - and setting width or height to 0 means "keep the input's dimension," which is how you resize only one axis.
The inputs beginners actually set
- image - what you're resizing.
- width / height - target;
0copies the input size; both can be overridden byget_image_size. - keep_proportion - the mode dropdown above.
- upscale_method - lanczos is sharpest for downscale, bicubic is the safe default.
- crop_position - center/top/bottom/left/right, used by
cropand the pad modes.
The rest are bonuses. mask resizes along with the image (nearest-exact is used for the mask so you don't get gray fringes). get_image_size copies dimensions from another image - handy when you want everything to match a reference. per_batch processes a big batch in chunks to tame memory use, and device lets you push it to the GPU (note: lanczos isn't supported on GPU, and it will error, not silently switch). Outputs are IMAGE, plus width and height ints and the resized mask.
Installing it
Same story as the rest of this pack - ComfyUI Manager, search "Image Misc", or:
cd ComfyUI/custom_nodes
git clone https://github.com/set-soft/ComfyUI-ImageMisc
cd ComfyUI-ImageMisc && pip install -r requirements.txt
Restart and you'll find it under image/manipulation. The only dependency beyond ComfyUI's own is the author's seconohe helper, which needs nothing extra.
Where people get burned
The two classics: choosing stretch when you meant resize and wondering why faces are distorted, and picking pad with a default black pad_color when you wanted edge fill. Also - because the mask output exists but the node is often used without one - if you don't connect a mask you still get a 64×64 empty tensor on the mask output; just don't wire it anywhere. The bundled resize.json example workflow walks through every mode side by side, which is the fastest way to internalize what each one does.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Image to resize | |
| width | INT | 5120–16384 | Used when no `get_image_size` is provided |
| height | INT | 5120–16384 | Used when no `get_image_size` is provided |
| upscale_method | COMBO | bicubic | Interpolation method for image resize |
| keep_proportion | COMBO | stretch | `stretch` doesn't keep the aspect ratio `pad` adds `pad_color` bars `pad_edge` fills using the edge color `resize` always keeps aspect, so W and H might change `crop` takes a portion of the image |
| pad_color | STRING | #000000 | Color for fill. Can be an hexadecimal (#RRGGBB). Can comma separated RGB values in [0-255] or [0-1.0] range. |
| crop_position | COMBO | center | Also used for `pad` |
| divisible_by | INT | 20–512 | Force the final size to be divisible by |
| maskopt | MASK | Optional mask for the image will be resized | |
| deviceopt | COMBO | 2 options: cpu, gpu | |
| get_image_sizeopt | IMAGE | Image size to use as reference | |
| per_batchopt | INT | 00–16384 | Process images in sub-batches to reduce memory usage. 0 disables sub-batching. |
| pad_transparencyopt | FLOAT | 1.00–1 | The transparency for the padded area for all modes except `edge_pixel`.1.0 is fully transparent, 0.0 is fully opaque. |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| width | INT | — |
| height | INT | — |
| mask | MASK | — |