Image Resolution Adaptive With X
Snap an Image to a Multiple of 8 (or Whatever You Need)
- image
- image
Most diffusion pipelines quietly require their input dimensions to be divisible by a specific number - 8 is the classic one, since that's the downsampling factor most VAEs use, and feeding in an image that isn't a clean multiple of it is a fast way to hit a shape-mismatch error deep in a node that isn't going to explain itself well. Image Resolution Adaptive With X exists purely to prevent that: hand it an image, tell it the base number and whether you'd rather crop or pad to get there, and it snaps the dimensions for you.
Three inputs, all things you'll set directly: image, mode (a choice between crop and expand - crop trims the excess off to reach a clean multiple, expand pads the image up to the next one instead of losing any content), and base (default 8, up to 2048) - the number your final width and height need to divide into evenly. Leave base at 8 for the overwhelming majority of workflows; you'd only raise it if a specific model or node you're using documents a stricter requirement. The output is image, resized to fit.
This is the node you reach for right after loading an arbitrary user-uploaded image and before it hits your sampler - uploads come in whatever size someone's phone or scanner produced, and that's essentially never a clean multiple of 8. crop mode is the simpler choice if losing a few edge pixels doesn't matter for your use case; expand is what you want when you can't afford to lose any content and would rather pad with extra canvas instead - just be aware that padding introduces new pixels that weren't in your original image, which matters if you're about to composite or inpaint and want the padding to not show up as visible content in the final result.
Installing it: ships in comfyui-mask-util, a small utility pack by longgui0318, better known for comfyui-magic-clothing, a virtual-try-on node that had a short-lived spike of Reddit attention in 2024. This pack looks like general glue split out of that project. The GitHub README is just the repo title with nothing further, so there's no official usage doc - this is read directly off the node's input/output schema.
Install through ComfyUI Manager (search "comfyui-mask-util") or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/longgui0318/comfyui-mask-util
Restart ComfyUI. No models to download - this is resize/crop arithmetic, nothing heavier.
Where it bites: crop mode trims from the image, which means if your subject is right up against the edge, you can lose part of it - this node doesn't know or care what's in the frame, it's purely doing dimension math. expand avoids that but changes your image's actual content (new padded pixels), which can look wrong if whatever comes next in your pipeline wasn't built expecting extra border. And if you're chasing a "size must be divisible by 8" error and this node doesn't fix it, double check the error isn't actually about a different dimension requirement further downstream (some models want multiples of 16, 32, or 64) - set base to match whatever the actual failing node demands rather than assuming 8 covers everything.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mode | COMBO | 2 options: crop, expand | |
| base | INT | 80–2048 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |