Nodes/comfyUI-tool-2lab/Image scale to side (2lab)
ComfyUI Node

Image scale to side (2lab)

Force an image to a target edge — the pack's better scaler

By AI2lab·Created 2 years ago·Updated 2 years ago· 23
Image scale to side (2lab)
  • image
  • image
side_length1024
sideLongest
upscale_methodnearest-exact
cropdisabled

When you need an image at a specific size but you don't care about the exact width and height - you care that the longest side is 1024, or that the shortest side is 512 - this is the node. It scales an image so a chosen side hits a target length, keeps the aspect ratio, and hands back a properly sized IMAGE. It's the same idea as ComfyUI's core ImageScale but organized around "pick a side, give it a length" instead of "give me exact dimensions."

That framing matters more than it sounds. For SDXL generation, the classic move is feeding the img2img or ControlNet path a reference at the model's native resolution - "longest side 1024" is exactly the constraint you want, and typing that once beats doing division in your head. For hi-res-fix-style setups, you often want the upscale input to be a fixed multiple of a base side, and this node expresses that directly.

The inputs that matter:

  • image - what you're scaling.
  • side_length - the target pixel length, default 1024. This is the number you actually think about.
  • side - which side the target applies to: Longest, Shortest, Width, or Height. Longest is the workhorse; Width/Height are for when you want a specific dimension and don't care what the other ends up being.
  • upscale_method - the resampling algorithm: nearest-exact, bilinear, bicubic, bislerp, area, lanczos. For downscaling, area is the honest choice (it anti-aliases properly); for upscaling, bicubic or lanczos look better than nearest except for pixel-art, where nearest-exact is correct.
  • crop - disabled or center. When the side you picked isn't the one that defines the crop, center trims the other axis to keep exact output dimensions.

Output is a single image, ready for a sampler, a VAE encode, or a save node.

Where it fits in the wider picture: this is a convenience scaler, not an upscaler in the "add detail" sense - it resizes, it doesn't invent pixels. If you want real upscaling (SUPIR, tiled diffusion, the whole ladder the community runs), this node is the step before that, normalizing an image to a size the pipeline expects. Don't expect magic detail from lanczos; expect correct dimensions.

One note that applies to the whole pack: this is the fuller of two nearly identical scale nodes. The pack also ships ImageScale_Side (2lab), an older version with fewer resampling options and a footgun of a default. Use this one.

Installing it

Part of AI2lab/comfyUI-tool-2lab. ComfyUI Manager → search "comfyUI-tool-2lab" → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/AI2lab/comfyUI-tool-2lab

Restart ComfyUI. No model downloads, light dependencies - this node is pure tensor math, no network.

Common issues

The main confusion is side selection: pick Longest with side_length 1024 and a portrait 768×1344 image comes back as ~585×1024 (longest side becomes 1024). If you expected 768×1024, that's not a bug - you wanted Width or Height. And on crop set to center, expect edges to get trimmed to hit exact dimensions; if your composition has a subject at the edge, disabled avoids surprise cuts. Downscaling with bicubic can look soft - reach for area when shrinking. There's nothing else to troubleshoot; the node is small and deterministic.

Category☁️2lab/image

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
side_lengthINT10241–18446744073709550000
sideCOMBOLongest4 options: Longest, Shortest, Width, Height
upscale_methodCOMBOnearest-exact6 options: nearest-exact, bilinear, bicubic, bislerp, area, lanczos
cropCOMBOdisabled2 options: disabled, center

Outputs (1)

NameTypeDescription
imageIMAGE