Nodes/OmniNodes/Resize to Multiple πŸ“
ComfyUI Node

Resize to Multiple πŸ“

Fix the 'not divisible by 8' error before the VAE complains

By TensorVizionΒ·Created 3 months agoΒ·Updated about 8 hours agoΒ· 0
Resize to Multiple πŸ“
  • image
  • image
  • width
  • height
  • summary
β—„modeβ–Ύβ–Ί
β—„multiple8β–Ί
β—„max_dimension1536β–Ί
β—„pad_color0,0,0β–Ί

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.

CategoryTensorVizion/Image

Inputs (5)

NameTypeDefaultDescription
imageIMAGEβ€”
modeCOMBO3 options: pad_to_multiple, crop_to_multiple, stretch_to_multiple
multipleINT82–128β€”
max_dimensionINT153664–8192β€”
pad_colorSTRING0,0,0β€”

Outputs (4)

NameTypeDescription
imageIMAGEβ€”
widthINTβ€”
heightINTβ€”
summarySTRINGβ€”