Nodes/ComfyUI-LogicUtils/Resize Longest To
ComfyUI Node

Resize Longest To

Fit an image inside a box, proportions intact

By aria1th·Created 3 years ago·Updated 7 months ago· 116
Resize Longest To
  • image
  • IMAGE
size512
method

The "fit inside a box" resize. You give it a size, and it scales the image so its longest side equals that number - the short side follows along to keep the aspect ratio. A landscape 1600×900 with size 512 comes out 512×288; a portrait 900×1600 comes out 288×512. Same longest edge either way, no distortion.

This is the resize you actually want most of the time and don't realize it. When you need every image to fit within a certain footprint - for thumbnails, for a memory-safe preprocessing step, for feeding a model that chokes above a certain resolution - capping the longest side is the clean way to do it. Portrait and landscape inputs both end up bounded, neither gets stretched, and you never have to branch on orientation.

How it works

It figures out which dimension is bigger, computes the scale factor that brings that dimension to your target size, and applies the same factor to the other dimension. That's it - one proportional resize keyed off the long edge. Because it's interpolation, shrinking is clean and enlarging just scales existing pixels (no new detail invented).

The inputs that matter

  • size (default 512) - the length you want the longest side to be. Everything scales relative to this.
  • method - LANCZOS, BICUBIC, or NEAREST. LANCZOS for photos and renders (sharpest downscale), NEAREST for masks or pixel art where you don't want edges blended.

image in, a single IMAGE out, aspect ratio preserved.

How it differs from its siblings

LogicUtils has a whole family of resize nodes and they're easy to mix up. This one bounds the longest side. ResizeImageNode forces an exact W×H (and will distort). ResizeScaleImageNode multiplies by a factor. ResizeImageResolution targets an overall resolution. If your goal is "make sure nothing is bigger than N on its longest edge," this is the one - and it's especially handy as a guard before an expensive step, since it caps worst-case size regardless of what someone loads.

Installing ComfyUI-LogicUtils

ComfyUI Manager: Install Custom Nodes → search "ComfyUI-LogicUtils" → install → restart. Or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/aria1th/ComfyUI-LogicUtils

Restart ComfyUI. No dependencies for this one.

Worth knowing

The pack is aria1th's (AngelBottomless) personal toolkit, deliberately under-documented - but a longest-side resize needs no manual. The only thing to keep straight is that size controls the long edge, not the total resolution and not both dimensions. Get that right and this becomes one of those quiet nodes you leave in every graph and never think about again.

Categoryimage

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
sizeINT512
methodCOMBO3 options: NEAREST, LANCZOS, BICUBIC

Outputs (1)

NameTypeDescription
IMAGEIMAGE