Image Resize by Shorter Side
Scale to a minimum dimension without distorting
- image
- IMAGE
JWImageResizeByShorterSide scales an image so its shorter edge equals the size you set, with the longer edge following to keep the aspect ratio. It's the "guarantee a minimum dimension" resize. Set size to 1024 and a 1600×900 photo becomes 1820×1024; a 900×1600 portrait becomes 1024×1820. The short side is pinned, the long side runs past it.
Why anchor to the shorter side? Because it's the "fill the frame" behaviour. If you're going to crop to a square or a fixed box afterward, resizing by the shorter side guarantees the image is at least that big in both directions, so the crop has full coverage with nothing to fill in. Contrast with the longer-side node, which fits inside a box and can leave the short side smaller than your target. Same family, opposite guarantee.
How it works
It measures the shorter of width/height, scales it to your size, and applies the same factor to the other dimension. Aspect ratio is preserved. It scales both ways - up if the source is small, down if it's large.
The inputs and outputs that matter
image(IMAGE) - the image (or batch) to resize.size(INT, default 512) - the target length of the shorter edge, in pixels. Type it, or wire an INT in to drive it dynamically.interpolation_mode(enum:bicubic/bilinear/nearest/nearest exact) - bicubic for smooth photo scaling, bilinear softer/faster, nearest for hard-edged content like masks or pixel art.- Output:
IMAGE- the resized image, aspect preserved.
How to install it
Part of jamesWalker55/comfyui-various, a pack of small utility nodes.
- ComfyUI Manager: search "Various ComfyUI Nodes by Type", install, restart. Red node in a downloaded workflow? Install Missing Custom Nodes.
- Manually:
Restart afterward. No models, no dependencies.cd ComfyUI/custom_nodes git clone https://github.com/jamesWalker55/comfyui-various
Under the jamesWalker55 category after restart.
Common issues
- The image is bigger than I expected. By design - pinning the shorter side means the longer side overshoots your number. If you meant "nothing larger than N," you want JWImageResizeByLongerSide instead. Getting these two backwards is the most common mistake with this node.
- The long side isn't divisible by 8. It's derived from the aspect ratio, so it can land on an odd value some models dislike. Follow with a crop (a crop-to-resolution node, or an exact resize) to snap it to a clean size.
- I need a specific final box. Resize by shorter side to guarantee coverage, then crop to your exact dimensions. That combo gives you a filled frame with no distortion and no letterboxing.
- Node is red / missing. The pack isn't installed. Install via Manager or clone the repo, then restart.
Rule of thumb: shorter-side + crop when you want to fill a target box; longer-side when you want to fit inside one. Same pack, two tools, and knowing which is which saves a lot of squinting at output dimensions.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| size | INT | 5120–99999 | — |
| interpolation_mode | COMBO | 4 options: bicubic, bilinear, nearest, nearest exact |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |