Nodes/Derfuu_ComfyUI_ModdedNodes/Image scale to side
ComfyUI Node Runs on cloud

Image scale to side

Resize an image by one edge, keep the aspect ratio

By Derfuu·Created 3 years ago·Updated 2 years ago· 455
Image scale to side
  • image
  • IMAGE
side_length1
side
upscale_method
crop

You want an image resized so its longest edge is exactly 1024px - and you don't want to do the aspect-ratio math yourself. That's this node. You pick which side to pin (longest, shortest, width, or height), give it a target length, and it scales the whole image to match while keeping the proportions. No stretching, no guessing the other dimension.

It comes from Derfuu_ComfyUI_ModdedNodes, a older utility pack built around exactly this kind of thing: automating the size calculations that ComfyUI's node graph would otherwise make you do by hand. This is one of the pack's genuinely useful bits.

Quick heads-up on the name: the pack has been reorganized over the years and the current builds register this as DF_Image_scale_to_side. "Image scale to side" (with spaces) is the older class name. Same node - see the DF_-prefixed page if that's what your install shows. More on why that matters below.

How it works

Under the hood it's a plain image resize - the same resampling ComfyUI's core scale nodes do - with a convenience layer on top that figures out the target dimensions from a single edge. Say your image is 1536x1024 and you set side_length 768 on the Shortest side: it scales so the short edge becomes 768, the long edge follows to 1152, aspect ratio preserved.

It's a pixel resize, not a smart upscaler. It doesn't add detail. Scaling up past the source resolution just interpolates - fine for fitting a canvas or prepping an input, not a substitute for a real upscale model when you need actual sharpness.

The inputs that matter

  • side_length (INT) - the target length in pixels for whichever side you choose.
  • side - Longest, Shortest, Width, or Height. This is the one people fumble. Longest/Shortest are aspect-agnostic (great for "fit within N px whatever the orientation"); Width/Height pin a specific axis.
  • upscale_method - the resampling filter: nearest-exact, bilinear, bicubic, bislerp, area, lanczos. For downscaling, area or lanczos look best. For upscaling, lanczos or bicubic. nearest-exact is for pixel art only.
  • crop - disabled (default) or center. Leave it disabled unless you specifically want a center crop.

Output is a single IMAGE, ready to save or feed downstream.

Where you'd actually use it

Two common spots. One: normalizing inputs - batch of mixed-size images, run them all through here to a fixed longest edge so your workflow behaves consistently. Two: the tail end of an ESRGAN upscale. Model upscalers like ImageUpscaleWithModel multiply by a fixed 4x, so you chain this after to land on an exact final size instead of whatever 4x happened to give you.

Common issues & troubleshooting

The node is red / "missing" after a ComfyUI update. Derfuu has a documented habit of deleting old node classes when reorganizing the pack rather than leaving them in as deprecated, which quietly breaks saved workflows. If this node vanished, update the pack via Manager and re-add it - it'll be the DF_-prefixed version now.

ModuleNotFoundError: No module named 'custom_nodes.Derfuu_ComfyUI_ModdedNodes' on load. Same root cause - an old workflow referencing a module path that moved. Update the pack, reload the graph, replace the stale node.

Output looks soft. You're scaling up with a pixel resize; there's no detail to add. Use a model upscaler for that and only use this to hit an exact size.

Aspect ratio came out wrong. You picked Width or Height when you wanted Longest/Shortest. The axis-specific options ignore orientation.

Install: ComfyUI Manager → search "Derfuu" → install → restart. Or cd ComfyUI/custom_nodes && git clone https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes and restart. No models or extra dependencies - it's pure Python.

CategoryDerfuu_Nodes/Modded nodes/Image

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
side_lengthINT1-9223372036854776000–9223372036854776000
sideCOMBO4 options: Longest, Shortest, Width, Height
upscale_methodCOMBO6 options: nearest-exact, bilinear, bicubic, bislerp, area, lanczos
cropCOMBO2 options: disabled, center

Outputs (1)

NameTypeDescription
IMAGEIMAGE