Nodes/comfyui-timesaver/TS Image Resize
ComfyUI Node

TS Image Resize

The resize node that finally covers every mode you actually use

By AlexYez·Created 2 years ago·Updated a day ago· 12
TS Image Resize
  • pixels
  • mask
  • IMAGE
  • width
  • height
  • MASK
target_width0
target_height0
smaller_side0
larger_side0
scale_factor0.0
keep_proportiontrue
upscale_methodbicubic
divisible_by1
megapixels1.00
dont_enlargefalse

Resizing is the boring work every workflow does twice before lunch: shrink the reference so it fits the model's native resolution, scale the output up to the size you want, match a video frame. Stock ComfyUI makes you pick a resize node, then wire width and height as separate numbers and hope the aspect ratio doesn't come out wrong. TS Image Resize bundles every common mode into one node and gives you an output that tells you what it actually did.

The README calls it "the resize node you actually want", and that's about right - it's the one I reach for when a workflow arrives and I don't want to think about interpolation math.

How it works

You pick exactly one mode by setting its value above 0; the rest stay off:

  • Exact size - target_width × target_height. With keep_proportion on (default) it cover-crops to fill while holding aspect; with it off it distorts to the exact size.
  • One side - smaller_side or larger_side sets just that side and derives the other. This is the one for "shrink every batch photo to max 1024 px".
  • Scale factor - multiply both dimensions by a float.
  • Megapixels - megapixels targets a total pixel budget (used only when no other mode is set). Great for "I want about a 1MP image" without caring which dimension wins.

Two guards make it forgiving: divisible_by snaps the final dimensions to a multiple (set 8 or 16 or 32 for samplers that care), and dont_enlarge blocks any upscale when the source is already smaller than the target - no more accidentally doubling a 512 px icon to 2048.

There's also an optional mask input that resizes together with the image, which saves you from forgetting to resize the mask and getting an inpainting region that's offset by exactly your downscale factor.

Inputs and outputs that matter

The required input is pixels (the image). Everything else is a mode selector or guard, so the honest shortlist is: pick smaller_side/larger_side for batch work, target_width/target_height when you know the destination, and divisible_by whenever the result feeds a sampler.

Outputs: IMAGE (resized), width and height as ints (handy for downstream routing logic like "now that it's 896 wide, use this branch"), and MASK (resized, or passthrough when nothing was connected).

Installation

This node ships in the comfyui-timesaver pack. ComfyUI Manager: search "Timesaver", install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/AlexYez/comfyui-timesaver
cd comfyui-timesaver
python -m pip install -r requirements.txt

Restart ComfyUI after. It's under TS/Image/Size in the right-click menu.

Where people get tripped up

  • Two modes set at once: only the first non-zero one wins, so zero the ones you're not using or you'll wonder why scale_factor is being ignored.
  • divisible_by and aspect ratio: snapping can drift the ratio a hair off. That's usually fine for latent input - samplers expect it - but don't use it when you need pixel-exact crops.
  • keep_proportion semantics: with both target dimensions set and the flag on, it crops to fill, not letterboxes. If you wanted letterboxing you're looking at a different tool.

It's a genuinely handy node - and the dont_enlarge guard alone is worth the install if you batch-resize mixed-size collections.

CategoryTS/Image/Size

Inputs (12)

NameTypeDefaultDescription
pixelsIMAGEImage to resize.
target_widthINT00–8192Exact target width in pixels. 0 = ignore this mode.
target_heightINT00–8192Exact target height in pixels. 0 = ignore this mode.
smaller_sideINT00–8192Resize so the shorter side equals this length in pixels. 0 = off.
larger_sideINT00–8192Resize so the longer side equals this length in pixels. 0 = off.
scale_factorFLOAT0.00–10Multiply both dimensions by this factor. 0 = off.
keep_proportionBOOLEANtrueKeep aspect ratio. With both target_width and target_height set, cover-crops to fill; off distorts to the exact size.
upscale_methodCOMBObicubicInterpolation method used for resizing.
divisible_byINT11–256Round the final width and height to a multiple of this value.
megapixelsFLOAT1.000–256Target total pixel count in megapixels. Used only when no other size mode is set.
dont_enlargeBOOLEANfalseNever upscale above the original size.
maskoptMASKOptional mask resized together with the image.

Outputs (4)

NameTypeDescription
IMAGEIMAGEResized image.
widthINTFinal output width in pixels.
heightINTFinal output height in pixels.
MASKMASKResized mask (passthrough when no mask is connected).