Nodes/ComfyUI-Apt_Preset/Image_Resize_sum
ComfyUI Node

Image_Resize_sum

Resize, pad or crop an image — and keep the receipt to undo it

By cardenluo·Created 2 years ago·Updated 18 days ago· 309
Image_Resize_sum
  • image
  • mask
  • get_image_size
  • mask_stack
  • IMAGE
  • mask
  • stitch
  • scale_factor
width512
height512
upscale_methodbilinear
keep_proportion
pad_colorblack
crop_positioncenter
divisible_by2
pad_mask_removetrue

This is the workhorse resize node in the pack, and the "sum" in the name is a hint: it bundles every common resize strategy - fit-inside, stretch, pad, edge-pad, crop-to-fit - into one node, and crucially it also hands you back a small data packet (stitch) that remembers exactly what it did. Wire that packet into Image_Resize_sum_restore later and you can undo the resize precisely, which is the whole point if you're shrinking an image down for a sampler pass and need to paste the result back onto the original canvas afterward.

The pattern this follows

If you've done inpainting work, you've probably run into the crop-then-stitch pattern popularized by nodes like Inpaint Crop and Stitch: shrink to a working size, process, then restore the original resolution without ever touching the pixels outside your working region. Image_Resize_sum is this pack's own version of that same idea, generalized to plain resizing rather than just inpainting. It's a genuinely useful pattern - it's much cheaper to run a sampler at 1024px than at your source's native 4000px, and stitching back means you're not stuck living with the downscaled result.

One real caveat: the stitch output here is a custom type (STITCH3) specific to this pack. It will not plug into another pack's crop-and-stitch nodes, and this pack's other crop family (Image_solo_crop/Image_solo_crop2) outputs a different bundle type (STITCH2) that won't plug into this node's restore node either. Match the family: Resize_sumResize_sum_data/Resize_sum_restore, solo_crop/solo_crop2Solo_data/solo_stitch.

The inputs and outputs that matter

  • width / height (INT, default 512 each) - your target dimensions.
  • keep_proportion - the mode: resize (scale to fit inside the bounds, no crop or fill - may leave the image smaller than your target on one axis), stretch (force the exact dimensions, distorting aspect ratio), pad (scale to fit, then letterbox the rest with a solid color), pad_edge (same idea, but fills with the image's own edge color instead of a flat color - usually less jarring), or crop (crop to the target aspect ratio first, then scale).
  • pad_color - the fill color for pad mode (black, white, red, green, blue, gray).
  • crop_position - anchor for crop mode (center, top, bottom, left, right).
  • divisible_by (INT, default 2) - rounds the final size to a multiple of this. Bump it to 8 or 64 if you're feeding a sampler that wants a clean VAE-aligned size.
  • pad_mask_remove (BOOLEAN, default true) - strips the mask over the padded area so downstream nodes don't treat the letterbox bars as part of your subject.
  • Optional mask and mask_stack (this pack's own MASK_STACK2 bundle) if you need the resize to carry a mask along with it.

Four outputs: the resized IMAGE, the carried-through mask, the stitch bundle (STITCH3 - feed to Image_Resize_sum_data or Image_Resize_sum_restore), and scale_factor (FLOAT) - the actual scale applied, useful if you want to reason about the resize without decoding the stitch bundle.

How to install it

ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manual:

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

install.bat is Windows-only; on Linux (comfy.icu included) run pip install -r requirements.txt directly. No model downloads for this node - it's pure image math.

Common issues

The most common trip-up is mode confusion: stretch and crop both hit your exact target dimensions but get there differently - stretch distorts the content, crop discards content. If your subject looks squished, you picked stretch when you wanted crop, or vice versa. Second, remember the stitch output is type-locked to this node's own restore/data nodes - if a wire won't connect where you expect, you're probably crossing it with the solo_crop family's STITCH2. And as with every node in this pack, a fresh install pulls in a large, mostly-unrelated requirements.txt (onnxruntime, gguf, transparent-background, and more for the pack's other 100+ nodes) - if the pack fails to import at all, check the ComfyUI console for the real missing-package error rather than assuming this specific node is broken.

CategoryApt_Preset/image

Inputs (12)

NameTypeDefaultDescription
imageIMAGE
widthINT5120–9999
heightINT5120–9999
upscale_methodCOMBObilinear5 options: nearest-exact, bilinear, area, bicubic, lanczos
keep_proportionCOMBO5 options: resize, stretch, pad, pad_edge, crop
pad_colorCOMBOblack6 options: black, white, red, green, blue, gray
crop_positionCOMBOcenter5 options: center, top, bottom, left, right
divisible_byINT20–512
pad_mask_removeBOOLEANtrue
maskoptMASK
get_image_sizeoptIMAGE
mask_stackoptMASK_STACK2

Outputs (4)

NameTypeDescription
IMAGEIMAGE
maskMASK
stitchSTITCH3
scale_factorFLOAT