Nodes/ComfyUI_BadgerTools/ImageScaleToSide-badger
ComfyUI Node

ImageScaleToSide-badger

Scale to a side length, not a resolution — orientation-agnostic resizing

By AbyssBadger0·Created 3 years ago·Updated 2 years ago· 8
ImageScaleToSide-badger
  • image
  • IMAGE
side_length1
side
upscale_method
crop

Most resize nodes make you say width and height. ImageScaleToSide-badger lets you say "make the longest side 2048" - and if you've ever written a workflow that has to handle both landscape and portrait images without knowing the orientation ahead of time, you know that's a genuinely different thing. This node scales an image so that one chosen side hits a target length, keeping the aspect ratio and letting the other dimension fall where it may. It's the "scale by proportion" node, and it's the natural partner for getImageSide-badger in the same pack.

The KB's upscaling essay opens with a reminder that "bigger" means different jobs, and one of the jobs is just more pixels, proportionally - no invented detail, just geometry. That's this node's lane. Cap a source at a max side before feeding it into a generative upscaler, normalize a batch of mixed-orientation images to a common side, shrink a huge image down to a tile-friendly size. Every case where you think in sides rather than sizes, this is the tool.

How it works

You pick which side to anchor, and it computes the other dimension to preserve aspect ratio. Under the hood it's using comfy.utils.common_upscale - the same upscale backend as ComfyUI's core image scale node - so the quality is on par with stock ComfyUI, not a toy implementation.

  • side - the dropdown that matters: Longest, Shortest, Width, or Height. Longest/Shortest auto-detect orientation; Width/Height anchor a specific axis.
  • side_length - the target length in pixels for the chosen side.
  • upscale_method - nearest-exact, bilinear, or area. For downscaling, area is the sane choice (it averages, avoiding the moiré you get shrinking with bilinear); bilinear is the general-purpose upscale; nearest-exact is the pixel-art one.
  • crop - disabled or center. This only matters if the scale result doesn't land on the target exactly - crop center trims to the target dimension.

Inputs and outputs

  • image - the IMAGE to scale.
  • side_length - INT, target side in pixels. Watch this one: the schema default is 1, so a fresh node will try to scale to a 1px side until you set it.
  • side, upscale_method, crop - the dropdowns above.

One output: the scaled IMAGE.

Installing it

In ComfyUI_BadgerTools: ComfyUI Manager → search "BadgerTools" → install, or

cd ComfyUI/custom_nodes
git clone https://github.com/AbyssYuan0/ComfyUI_BadgerTools

Restart after install. No model files - it uses ComfyUI's own resampling. Pack tax applies: heavy requirements install and import at startup regardless.

Gotchas

  • side_length defaults to 1. The most common "why is my image tiny?" moment with this node is a fresh node running at its default. Set it before you hit Queue.
  • Longest/Shortest read the current image. If you're chaining rescales, the anchor re-reads each time, so "longest = 1024" stays correct even after the image orientation changes downstream - which is exactly why this node exists.
  • Rounding: the computed other side is rounded up with math.ceil, so you may see results a pixel or two over a clean multiple. Harmless, but it explains the occasional off-by-one.

No community threads exist for this node - personal-pack utility, thin README. But "scale by side, not by size" is a pattern the stock nodes make annoyingly awkward, and this is a clean, standard-quality answer to it. Pair it with getImageSide-badger and you can build orientation-proof pipelines that never hardcode a resolution.

Categorybadger

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
side_lengthINT11–4096
sideCOMBO4 options: Longest, Shortest, Width, Height
upscale_methodCOMBO3 options: nearest-exact, bilinear, area
cropCOMBO2 options: disabled, center

Outputs (1)

NameTypeDescription
IMAGEIMAGE