Nodes/Comfyui_PDuse/PDIMAGE:LongerSize
ComfyUI Node

PDIMAGE:LongerSize

LongerSize — scale the long edge to a target, keep the ratio, done

By 7BEII·Created 2 years ago·Updated 15 days ago· 53
PDIMAGE:LongerSize
  • image
  • IMAGE
size512
interpolationbicubic

The most common resize in all of ComfyUI is probably "make the long side 1024, keep the aspect ratio." PDIMAGE:LongerSize is exactly that, in a single node with three inputs. No method dropdowns, no fit logic, no padding math - just pick a long-edge length and it scales the image so the longest side lands on it, with the short side following proportionally.

Its simplicity is the feature. When you're standardizing a mixed pile of images for a model input or a batch comparison and all you care about is "nobody's long edge exceeds X," this node is the least-thought-required option in the pack.

How it works

Under the hood it reads the tensor's [H, W], decides which is longer, computes the scale factor, and resizes with ComfyUI's common_upscale. For a landscape image, size becomes the new width and height scales down by the same factor; for a portrait, size becomes the new height. Because it's a proportional resize, the short edge just follows along - you get 1536×1024 or 1024×1024 or whatever the ratio dictates, not a forced square.

interpolation is where you pick the resample quality: nearest, bilinear, bicubic (default), area, or nearest-exact. If you're shrinking, area is the smart choice (it averages pixels and avoids moiré); for upscaling, bicubic is the safe default. The node even maps nearest-exact correctly - a small detail that says the author cared about the edge cases.

The inputs that matter

  • image (IMAGE) - source.
  • size (INT, default 512, up to 99999) - target length of the longer side.
  • interpolation - resample method, default bicubic.

One output: IMAGE.

Where to use it

Pre-flight sizing is the natural home: cap every frame at 1024 before VAE encoding, normalize a batch of mixed-resolution renders for comparison, or shrink large assets down before feeding a preview. It's also handy as a reducer - take a 4096px render and drop it to 1024 for a quick iteration without changing the rest of the graph.

One thing it won't do: enforce a multiple of 8, pad to an exact canvas, or crop. If you need those, PDImageResize in the same pack has multiple_of and pad/crop methods, and PDImageResizeV2 handles aspect-ratio-fit. This node is deliberately the dumb, fast, one-job version.

Gotchas

There aren't many, because there isn't much to get wrong. The short edge can end up at an awkward value (e.g. a 3:4 image at long-edge 1000 gives 750 on the short side) - fine for previews, annoying if the next node demands multiples of 8. And "longer side" is evaluated per-frame; in a batch where every frame must share dims (which ComfyUI batches do), they'll all be resized to the same long edge and their differing ratios will produce differing short edges - which can't coexist in one batch. For mixed-ratio batches, normalize to a fixed W×H with a crop/pad node instead. For single images and uniform batches, this is as painless as resizing gets.

Install

ComfyUI Manager: search PDuse (repo 7BEII/Comfyui_PDuse), install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse
cd Comfyui_PDuse
pip install -r requirements.txt

Restart and it appears as PDIMAGE:LongerSize under PDuse/Image. One number, one output, no surprises.

CategoryPDuse/Image

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
sizeINT5121–99999
interpolationCOMBObicubic5 options: nearest, bilinear, bicubic, area, nearest-exact

Outputs (1)

NameTypeDescription
IMAGEIMAGE