Nodes/ComfyUI_AIMZ/AIMZ Auto Multiple Pad
ComfyUI Node

AIMZ Auto Multiple Pad

Pad anything to a divisible resolution, and remember how you did it

By AIMZ-GFX·Created 28 days ago·Updated 17 days ago· 3
AIMZ Auto Multiple Pad
  • image
  • mask
  • image
  • mask
  • width
  • height
  • count
  • left
  • right
  • top
  • bottom
  • pad_info
multiple32
pad_modeconstant
pad_colorwhite

Video models are picky about dimensions. MiniMax H3 wants resolutions divisible by 32; LTX and a lot of the Wan family want multiples of 8 or 16. Feed them a 1080x720 image and you'll get an error or - worse - silent padding that shifts your composition. AIMZ Auto Multiple Pad is the node that solves that, and it's built for exactly the workflows this pack is aimed at.

It pads an image, a mask, or a whole batch of video frames up so both width and height land on whatever multiple you pick (default 32). Padding is centered - it splits the extra pixels evenly between left/right and top/bottom - and it hands you back a pad_info object so you can reverse it later without doing any arithmetic yourself.

How it works

The math is dead simple: pad = (ceil(w / multiple) * multiple) - w, then split that in half, extra pixel goes to the right/bottom. The clever part is what it does with those pixels. You get four pad modes:

  • constant - solid color, default white. Color is a string, and the parser is forgiving: white, black, gray, hex like #ffffff, or normalized RGB like 1,1,1.
  • reflect - mirrors the image at the edge. If your pad is bigger than the image itself, this mode would fail, so the node automatically falls back to replicate rather than crash.
  • replicate - stretches the edge pixels out.
  • circular - wraps around.

That last fallback is a nice touch: reflect-mode crashes are one of those "why is my workflow suddenly broken" errors that pad nodes generate, and this one just quietly refuses to.

If you pass a mask in alongside the image, it gets padded with the identical offsets, so your mask and image stay pixel-aligned through the whole pipeline.

Inputs and outputs

You set three things: multiple (the divisibility target), pad_mode, and pad_color (only used when mode is constant). Optionally feed image and mask.

The outputs are where this node earns its keep. Besides the padded image and mask, you get width, height, and count (frame count) - a built-in replacement for GetImageSizeAndCount that's None-safe - plus the raw left, right, top, bottom offsets and a pad_info object. That pad_info is the whole reason the companion AIMZ Auto Multiple Unpad node can restore your original dimensions losslessly later.

Installing it

This is part of the ComfyUI_AIMZ pack. In ComfyUI Manager → Custom Nodes Manager, search comfyui_aimz or AIMZ, Install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/AIMZ-GFX/ComfyUI_AIMZ.git

No models to download, no dependencies beyond what's already there.

Where it bites

The classic flow is pad → VAE encode → sample → VAE decode → unpad, and the pad_info is the handoff. Wire pad_info from this node into the Unpad node and you never think about offsets again. Skip it and you're manually re-entering left/right/top/bottom numbers that you'll absolutely get wrong once your source resolution changes.

One honest caveat: centered padding means the padding color shows on all four edges. White is the default, and if your video's border isn't white, you'll see a frame around the result. Either match pad_color to your content's edge, or lean on replicate/reflect for natural-looking borders. And if both image and mask are None, it passes None through with zeroed outputs instead of throwing - which is what lets you build conditional branches that only sometimes have data.

CategoryAIMZ/Image

Inputs (5)

NameTypeDefaultDescription
multipleINT321–512Resolution multiple (e.g., 32 for MiniMax-H3)
pad_modeCOMBOconstant4 options: constant, reflect, replicate, circular
pad_colorSTRINGwhiteUsed when pad_mode is constant (e.g. 'white', 'black', '1,1,1', '0,0,0', '#ffffff')
imageoptIMAGEOptional image/video frame batch input. If None, returns None without error.
maskoptMASKOptional mask input. If provided, padded with same padding.

Outputs (10)

NameTypeDescription
imageIMAGE
maskMASK
widthINT
heightINT
countINT
leftINT
rightINT
topINT
bottomINT
pad_infoPAD_INFO