Image Resize to Closest SDXL Resolution
Snap any image to a valid SDXL size
- image
- IMAGE
- WIDTH
- HEIGHT
SDXL is fussy about resolution. It was trained on roughly one-megapixel images sorted into a fixed set of aspect-ratio "buckets" - 1024×1024, 1152×896, 832×1216, 1344×768, and a handful of others. Feed it something well outside those and you get the classic SDXL failure modes: duplicated heads, stretched bodies, mushy composition. This node exists to keep you inside the lines. You hand it an image of any size, and it resizes to whichever official SDXL bucket is closest to the aspect ratio you already have.
That makes it a img2img and ControlNet convenience node. You drag in a reference photo that's 1920×1280 or some phone-camera oddball ratio, and instead of eyeballing the nearest legal size yourself, you let the node pick. It's the kind of thing you don't think about until a batch comes out full of two-headed people and you realize you were sampling at 1500×1000.
How it works
It compares your image's aspect ratio against the SDXL bucket list, finds the nearest match, and scales the whole image to those exact dimensions. Worth being clear about one thing: this is a resize, not a crop. If your source ratio doesn't line up perfectly with the target bucket, the image gets slightly stretched to fit rather than trimmed. For most photos the distortion is tiny and nobody will notice. For anything where proportions matter, crop to roughly the right ratio first, then let this node do the final snap.
Inputs and outputs
- image - the image to resize.
- interpolation_mode -
bicubic,bilinear,nearest, ornearest exact. For photographic content leave it on a smooth mode (bicubic is the sensible default);nearestonly makes sense for pixel art or hard-edged graphics where you don't want blurring.
Three outputs: the resized IMAGE, plus WIDTH and HEIGHT as integers. Those two int outputs are the genuinely useful part - wire them straight into an Empty Latent (or anything else that needs the dimensions) so your latent matches the image without you retyping numbers. That's the whole point of exposing them.
Installing it
The node lives in this pack's comfyui_image_ops file. Easiest path is ComfyUI Manager: open it, search for Various ComfyUI Nodes by Type (the repo is comfyui-various), install, restart. Or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/jamesWalker55/comfyui-various
Restart ComfyUI afterward. There are no model files and no extra Python packages to install for this one - the pack only needs an extra dependency (OpenEXR) for a completely unrelated optical-flow node you're not using here.
Common issues
The biggest one is using it on the wrong model. This node knows SDXL buckets and nothing else. On SD 1.5 (which wants 512-ish) or on Flux/SD3 (which are far more flexible about resolution) it'll happily snap you to a 1024-class size that isn't what those models want - pointless at best, worse at worst. It's an SDXL tool; keep it in SDXL graphs.
Second: don't expect it to fix a badly cropped subject. It picks the closest bucket by ratio, so an extreme panorama gets forced toward the widest legal bucket and stretched to get there. Pre-crop to a sane ratio and the snap is basically lossless.
Finally, if this node shows up red as a missing node when you load someone else's workflow, that's just the pack not being installed yet - these JW-prefixed nodes travel around inside shared workflows a lot. Run ComfyUI Manager's "Install Missing Custom Nodes," or clone the repo above, and it'll resolve.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| interpolation_mode | COMBO | 4 options: bicubic, bilinear, nearest, nearest exact |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| WIDTH | INT | — |
| HEIGHT | INT | — |