🖼️ Resize to Aspect Ratio
Resize an image to a ratio without the funhouse-mirror effect
- image
- resized_image
- width
- height
- resolution_label
Every img2img workflow eventually hits the same wall: you've got an image at one aspect ratio, and the model wants another. Drag a 3:2 photo into a 16:9 latent and either it stretches - faces get wide, bodies elongate - or you're hand-cropping in an external editor and re-importing. AspectRatioResizeImage collapses that whole detour into one node: it computes the target size from the ratio, crops or stretches to fit, and hands you back a properly-sized tensor ready for the VAE.
If you used its sibling AspectRatioImageSize, this is the same priority logic applied to actual pixels. Set both width and height and it obeys you; set one and it derives the other; set both to zero and it targets a ~1-megapixel size in the chosen aspect_ratio (rounded to a multiple of 16). Then it resizes with LANCZOS and, unlike the pure calculator sibling, it always snaps the final dimensions to multiples of 16 - so the output is safe to feed into a latent encoder without worrying about VAE alignment complaints.
Stretch vs Crop - pick your poison
The crop_method dropdown is the one that actually matters:
- Stretch (default): a straight resize. Fast, nothing lost, but if the source ratio and target ratio differ, geometry gets distorted. Fine for subtle differences, bad for going from 1:1 to 21:9.
- Crop: center-crops the source to the target ratio first, then resizes without distortion. You lose the edges - but a 16:9 crop of a portrait photo keeps people looking like people.
For anything involving faces or recognizable geometry, use Crop. The trade is that the node always crops to the center, so if your subject is off to the side you'll want to crop or frame upstream instead.
The trap: it only touches the first frame
Here's the thing the info panel won't tell you: the node pulls image[0] - the first frame of whatever batch it receives - and returns a fresh batch of one. Feed it a video, an image sequence, or a batched set and the rest of the frames are silently ignored. That makes it a node you use before you build a batch, not after. Want to resize ten images? That's a per-image job (or a different tool), because this one will happily drop nine of them.
Wiring it up
- Inputs:
image(IMAGE), pluswidth,height,aspect_ratio,direction,crop_method. - Outputs:
resized_image(IMAGE) - wire this into VAE Encode for img2img, into a ControlNet preprocessor, or straight into an upscaler. Thewidth,heightandresolution_labeloutputs mirror what actually got produced, so you can display "1344×768" next to the preview or pass the numbers downstream.
One honest note on quality: this is a plain LANCZOS resize, not a generative upscaler. Going up from a small source gives you soft, interpolated pixels - if you want the detail-enhancing kind of enlargement, generate at native resolution and use a real upscaler pass (ESRGAN-class models or a ControlNet Tile pass) rather than stretching pixels.
Install
The README never documents installation, so clone it the standard way:
cd ComfyUI/custom_nodes
git clone https://github.com/comfyuistudio/ComfyUI-Studio-nodes
Restart and you'll find it under "STUDIO NODES". Dependencies are only numpy, torch and Pillow - already present. If you use ComfyUI Manager, its catalog search may not surface this pack (it's a small, single-commit repo not reliably in the registry), so paste the git URL into Manager's install-by-URL field instead.
Worth repeating the pack's caveat: it's basically unmaintained and tiny (4 stars, one commit). The code is short enough to skim - do that before you rely on it in a production workflow, especially given the batch limitation above.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 00–4096 | — |
| height | INT | 00–4096 | — |
| aspect_ratio | COMBO | 1:1 | 10 options: 1:1, 16:9, 5:4, 4:3, 3:2, 2.39:1, +4 |
| direction | COMBO | Horizontal | 2 options: Horizontal, Vertical |
| crop_method | COMBO | Stretch | 2 options: Stretch, Crop |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| resized_image | IMAGE | — |
| width | INT | — |
| height | INT | — |
| resolution_label | STRING | — |