Nodes/Image Misc/Resize Image (KJ/SET)
ComfyUI Node

Resize Image (KJ/SET)

One resize node that stretches, pads, crops, or blurs — the KJ/SET workhorse

By set-soft·Created about a year ago·Updated 8 months ago· 2
Resize Image (KJ/SET)
  • image
  • mask
  • get_image_size
  • IMAGE
  • width
  • height
  • mask
width512
height512
upscale_methodbicubic
keep_proportionstretch
pad_color#000000
crop_positioncenter
divisible_by2
device
per_batch0
pad_transparency1.0

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_position picks 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; 0 copies the input size; both can be overridden by get_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 crop and 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.

Categoryimage/manipulation

Inputs (13)

NameTypeDefaultDescription
imageIMAGEImage to resize
widthINT5120–16384Used when no `get_image_size` is provided
heightINT5120–16384Used when no `get_image_size` is provided
upscale_methodCOMBObicubicInterpolation method for image resize
keep_proportionCOMBOstretch`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_colorSTRING#000000Color for fill. Can be an hexadecimal (#RRGGBB). Can comma separated RGB values in [0-255] or [0-1.0] range.
crop_positionCOMBOcenterAlso used for `pad`
divisible_byINT20–512Force the final size to be divisible by
maskoptMASKOptional mask for the image will be resized
deviceoptCOMBO2 options: cpu, gpu
get_image_sizeoptIMAGEImage size to use as reference
per_batchoptINT00–16384Process images in sub-batches to reduce memory usage. 0 disables sub-batching.
pad_transparencyoptFLOAT1.00–1The transparency for the padded area for all modes except `edge_pixel`.1.0 is fully transparent, 0.0 is fully opaque.

Outputs (4)

NameTypeDescription
IMAGEIMAGE
widthINT
heightINT
maskMASK