Nodes/LF Nodes/Resize image by edge
ComfyUI Node

Resize image by edge

Aspect-preserving resize by long or short side

By lucafoscili·Created 2 years ago·Updated about a year ago· 50
Resize image by edge
  • image
  • ui_widget
  • image
  • image_list
  • count
longest_edgefalse
new_size1024
resize_methodbicubic

A lot of prep steps - feeding a ControlNet preprocessor, capping an image at a max dimension before it hits a slow node, matching a checkpoint's preferred resolution ceiling - want you to resize by one edge while keeping the aspect ratio intact, not force everything into a square. LF_ResizeImageByEdge does that specific job: pick a target size, pick which edge it applies to, and the other dimension scales proportionally on its own.

The longest_edge boolean is the key decision here: set it true and new_size caps the longer side of your image (so a 2000×1000 image resized to 1024 becomes 1024×512); leave it false (the default) and new_size targets the shorter side instead (that same 2000×1000 image resized to 1024 becomes 2048×1024). Which one you want depends on the job - capping the longest edge is typical when you're trying to bound total pixel count or fit within a max resolution; targeting the shortest edge is more common when a downstream model wants a guaranteed minimum dimension regardless of aspect ratio. resize_method picks the resampling algorithm: bicubic (default) for general smoothness, nearest/nearest exact when you need hard edges preserved (masks, pixel art), bilinear/linear in between.

Outputs: image, the resized result; image_list, the same as a list if you fed a batch; count, how many images came out. There's an optional ui_widget slot rendering a tree view on the node - display only.

This is the node you reach for far more often than LF_ResizeImageToSquare in a typical workflow, precisely because most prep steps care about a size ceiling or floor, not a forced aspect ratio. ControlNet preprocessors in particular tend to have a sweet spot resolution - feed them something enormous and processing slows down for no quality benefit; feed them something tiny and detail suffers. Capping the longest edge before that step is a cheap, standard fix.

Installing it. ComfyUI Manager: search "LF Nodes," install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/lucafoscili/lf-nodes, then restart. Pull from that repo - comfyui-lf, linked from comfy.icu, is the pack's original, now-archived home; the author's current work is at lf-nodes. No models, no heavy dependencies.

Where people get tripped up. The longest_edge toggle is the thing to get right before assuming the node is misbehaving - flipping it is the single most common source of "why is my output the wrong size," since targeting the long edge versus the short edge on a non-square image produces genuinely different results, not a subtle variation. If you actually want a hard square output rather than aspect-preserved scaling, this is the wrong node entirely - LF_ResizeImageToSquare, from the same pack, is built for that and crops instead of just scaling.

Category✨ LF Nodes/Image

Inputs (5)

NameTypeDefaultDescription
imageIMAGEInput image tensor or a list of image tensors.
longest_edgeBOOLEANfalseResizes the image by the longest side if set to True. Otherwise, resizes by the shortest side.
new_sizeINT1024The size of the longest edge of the output image.
resize_methodCOMBObicubicMethod to resize the image.
ui_widgetoptKUL_TREE[object Object]

Outputs (3)

NameTypeDescription
imageIMAGE
image_listIMAGE
countINT