Image scale to side
Resize an image by one edge, keep the aspect ratio
- image
- IMAGE
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, orHeight. This is the one people fumble.Longest/Shortestare aspect-agnostic (great for "fit within N px whatever the orientation");Width/Heightpin a specific axis.upscale_method- the resampling filter:nearest-exact,bilinear,bicubic,bislerp,area,lanczos. For downscaling,areaorlanczoslook best. For upscaling,lanczosorbicubic.nearest-exactis for pixel art only.crop-disabled(default) orcenter. 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.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| side_length | INT | 1-9223372036854776000–9223372036854776000 | — |
| side | COMBO | 4 options: Longest, Shortest, Width, Height | |
| upscale_method | COMBO | 6 options: nearest-exact, bilinear, bicubic, bislerp, area, lanczos | |
| crop | COMBO | 2 options: disabled, center |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |