Nodes/antrobots ComfyUI Nodepack/Scale Image to Size
ComfyUI Node

Scale Image to Size

Scale Image to Size

By antrobot1234·Created 3 years ago·Updated about a year ago· 28
Scale Image to Size
  • image_in
  • image_out
desired_size1024
sizing_modebalanced
scale_modebilinear

This is a resize node with one opinion baked in: you give it a target size for one dimension and it works out the other one to keep the aspect ratio. No stretching, no squashing. It's the "I just need this image to be about 1024 on a side" node, and it saves you from the fiddly math of matching an arbitrary aspect ratio to a fixed target.

Why you'd reach for it

ComfyUI's built-in "Upscale Image" nodes make you either pick an exact width and height (which distorts anything that isn't the same ratio) or pick a multiplier (which means you have to know the source size first). Neither is what you usually want. Most of the time the actual goal is "make the short edge 1024 so it's safe to run through an SDXL pass," or "cap the long edge at 1536 so this doesn't blow up VRAM." scale expresses exactly that in one number.

It's a plain pixel resize, not a generative upscaler - so it's the right tool for fitting an image to a resolution before a sampling pass, not for adding detail. For that second job you'd follow it with a hi-res fix or a proper upscale model; the modidex upscaling notes are blunt that a pixel resize alone won't invent detail, it just changes dimensions.

How it works

You give it a desired_size and a sizing_mode, and it computes a single scale factor from the source image so the aspect ratio is preserved. The mode decides which dimension the target applies to:

  • balanced (the default) - the sensible middle option; use this when you just want the image "around" the target size.
  • larger - keys the scale off the image's longer dimension, so the long edge lands near desired_size. Good for capping the maximum so nothing exceeds your VRAM budget.
  • smaller - keys off the shorter dimension, so the short edge lands near desired_size. Good for guaranteeing a minimum resolution before a diffusion pass.

The inputs that matter

  • desired_size - the target pixel length for whichever dimension your mode selects. Defaults to 1024.
  • sizing_mode - balanced / larger / smaller, per above. This is the one that changes behavior, so get it right for your intent.
  • scale_mode (optional) - the interpolation: nearest, nearest-exact, bilinear (default), or bicubic. Bilinear is fine for almost everything; bicubic is marginally sharper on downscales; nearest is only for pixel-art or mask-like content where you don't want blending.

Input is image_in, output is a single image_out you wire straight into your next node.

Installing it

Via ComfyUI Manager, search antrobots ComfyUI Nodepack. Or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/antrobot1234/antrobots-comfyUI-nodepack

Restart ComfyUI. No models, no extra dependencies - it's a straight image operation.

Common issues

The one gotcha is expecting desired_size to set both dimensions. It doesn't - it sets one and derives the other from the aspect ratio, which is the whole point. If you actually need an exact WxH (for a model that demands a specific resolution), this isn't your node; use a fixed-size resize or crop after it.

The other thing to keep straight is larger vs smaller. If your images are coming out bigger than you expected, you probably wanted larger (cap the long edge) but picked smaller (which pushes the short edge up to the target and lets the long edge run past it). Swap the mode and re-check.

Categoryantrobots-ComfyUI-nodepack/image-handling

Inputs (4)

NameTypeDefaultDescription
image_inIMAGE
desired_sizeINT10241–9223372036854776000
sizing_modeCOMBObalanced3 options: balanced, larger, smaller
scale_modeoptCOMBObilinear4 options: nearest, nearest-exact, bilinear, bicubic

Outputs (1)

NameTypeDescription
image_outIMAGE