Resize to Multiple π
Fix the 'not divisible by 8' error before the VAE complains
- image
- image
- width
- height
- summary
Every img2img or inpaint workflow eventually feeds an arbitrary source image into a latent pipeline, and the latent pipeline wants dimensions divisible by 8 (the SD/SDXL VAE's downsampling factor). Feed it a 1373Γ915 image and you get an error, or worse, a silent mis-shape. Resize to Multiple π is the small-but-constantly-needed fix: it resizes an image so both dimensions land on a multiple of N without distorting aspect ratio.
It's the kind of utility that looks boring and saves you ten minutes a day once it's in your graph. If you're on newer models - some video VAEs expect 16 or 32 - the multiple is adjustable rather than hardcoded.
How it works
Three modes, all preserving aspect ratio:
- pad_to_multiple - scales the image down/up only as needed to fit within a multiple-of-N box, then pads the remainder with
pad_color(letterbox style). Never crops content; you may get solid-color bars. - crop_to_multiple - scales to cover the box, then center-crops the overflow. Never adds borders; you may lose edge content.
- stretch_to_multiple - resizes each dimension independently to the nearest multiple. Fastest, but it will distort aspect ratio if the source isn't already close to the target shape.
max_dimension (default 1536) caps the output size so a 4K source doesn't balloon into VRAM-obliterating territory, and pad_color (default 0,0,0) sets the letterbox color.
The inputs and outputs
Inputs: image, mode, multiple (2β128, default 8), max_dimension (64β8192), pad_color. Outputs: the resized image, plus width and height INTs (handy if something downstream needs the real numbers) and a summary. Wiring width/height into nodes that want explicit dimensions saves you from hardcoding a value that can drift.
For inpainting specifically, pad_to_multiple is usually the right default - you want to keep all the source pixels, bars and all, and the mask follows the image. For photo crops where you'd rather lose an edge than gain a bar, crop_to_multiple.
Installing it
Part of the OmniNodes pack:
cd ComfyUI/custom_nodes/
git clone https://github.com/TensorVizion/OmniNodes
Restart ComfyUI (or search "OmniNodes" in ComfyUI Manager). No extra dependencies - it's torch and torch.nn.functional. Registers under TensorVizion/Image. If it doesn't appear after install, restart completely and check the terminal for [OmniNodes] β
Loaded lines.
One honest note: this handles the multiple-of-N requirement, not the resolution sweet spot. A 512Γ512-capped image at multiple 8 is valid latent input but will look soft; pair it with a proper upscale or resolution node if quality is the goal. For just getting an image into a shape the VAE will accept, it's the node you'll stop noticing - which is the highest compliment.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | β | |
| mode | COMBO | 3 options: pad_to_multiple, crop_to_multiple, stretch_to_multiple | |
| multiple | INT | 82β128 | β |
| max_dimension | INT | 153664β8192 | β |
| pad_color | STRING | 0,0,0 | β |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |
| width | INT | β |
| height | INT | β |
| summary | STRING | β |