Image Resize
Aspect-locked resize that stops where you want it to
- image
- image
- width
- height
Most resize nodes make you pick an exact width and height, which forces you to either stretch the image or remember to compute the second dimension yourself. Image Resize (imageResize) from the zsq_prompt pack sidesteps that: you pick an anchor side (WIDTH or HEIGHT), give it a ratio, and it scales the other side to match, preserving aspect ratio - then optionally caps the result at a max_side so you can't accidentally upscale a 512px image to 8000px.
How it works
The node reads the image's current dimensions, picks whichever side you anchored on, multiplies it by ratio, clamps it to max_side, then derives the other dimension from the aspect ratio. That's the whole trick, and it's a good one: "make this 1024 wide" becomes one input instead of "what's the height going to be?"
Under the hood it uses ComfyUI's own common_upscale, so the five upscale_method options are the same ones you know from core: nearest-exact, bilinear, area, bicubic, bislerp. For downscaling, area is the quality pick; for upscaling, bicubic is the usual safe choice. The crop option (disabled / center) handles tiny aspect mismatches the same way core does.
One quirk: setting ratio to 0 passes the image through untouched and returns its current dimensions. Handy as a bypass.
Inputs and outputs that matter
- side - which dimension to anchor on:
WIDTHorHEIGHT. - ratio - scale factor on the anchor side (0–8, default 1.0).
- max_side - the cap. Default 1024, which is SDXL's native territory.
- upscale_method - interpolation. Set once and forget.
- crop -
disabledorcenterfor aspect correction. - Outputs: image, plus width and height INTs of the result. Those two are handy if you need the actual final dimensions downstream (like for setting up a latent of the same size).
Where it fits
Preparing reference images for img2img or ControlNet is the sweet spot: downscale a 2048px render to a 1024 base, feed it in, and keep the aspect ratio intact. It's also the natural counterpart to the pack's imageScaleDown - that one pins an exact size; this one pins an aspect-preserving size with a cap.
A note from the upscaling playbook: for a "just make it bigger" job this is the non-generative path (Lanczos/bicubic territory), not the "add detail" path - if you want detail that was never there, you want a model-based upscaler or ControlNet Tile instead. This node is the quick, lossless-ish resize.
Installing zsq_prompt
One pack, all nodes. ComfyUI Manager → search zsq_prompt → install, then restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/windfancy/zsq_prompt
Restart ComfyUI. The pack installs a heavy dependency set (transformers, opencv-python, opencv-contrib-python, scikit-image, timm, onnx, ultralytics) - overkill for this node, but it's a shared install, so you eat the cost once. If Manager flags "conflicting with zsq_prompt" on a downloaded workflow, that's dependency-overlap noise; ignore it unless the pack is actually installed. No model files needed.
Gotchas
- It can upscale as well as downscale - there's no guard preventing
ratio> 1. Blowing a small image up with bicubic is fine for reference work but won't create new detail. max_sideonly caps, it doesn't enforce a minimum. Ask for width 64 and you'll get a tiny image.- Step is 8 on
max_side, which keeps you in latent-friendly territory - but the final height is computed, so it may not land on a multiple of 8. Pair with a crop/pad step if your sampler is picky.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| side | COMBO | WIDTH | 2 options: WIDTH, HEIGHT |
| max_side | INT | 102464–16384 | — |
| ratio | FLOAT | 1.00–8 | — |
| upscale_method | COMBO | 5 options: nearest-exact, bilinear, area, bicubic, bislerp | |
| crop | COMBO | 2 options: disabled, center |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| width | INT | — |
| height | INT | — |