Nodes/ComfyUI-Rennart/🖼️ Rennart Image Pad
ComfyUI Node

🖼️ Rennart Image Pad

Round Your Canvas Up Instead of Cropping It Away

By Rennart2025·Created 2 months ago·Updated 4 days ago· 4
🖼️ Rennart Image Pad
  • image
  • mask
  • image
  • mask
  • width
  • height
◄multiple32►
◄pad_modeedge►
◄resize_positioncenter►
◄maskingmasked►
◄background_colorgray►
◄feathering0►

You've got a 1648×912 image and something downstream wants multiples of 32 or 64. Shave pixels off or add pixels on - genuinely different choices. Every pack ships a crop node, including this one (✂️ Rennart Image Crop, rounds down from the centre). Rennart Image Pad is the other half, for when the framing matters and you'd rather grow the canvas than lose the corners. It's also the first move of any outpainting workflow - bigger canvas, mask the new area, let the model fill it - which is why this node bothers to output a mask.

What it actually does

One line of arithmetic, per axis: ceil the size to the nearest multiple.

((size + multiple - 1) // multiple) * multiple

With multiple = 32, a 1648-wide image becomes 1664 - sixteen pixels added, nothing removed. Already on the grid? It's a pass-through: no resampling, nothing stretched.

The fill itself is NumPy's pad, which is why the four pad_mode options read like its docs: constant (solid colour), edge (smear border pixels outward), reflect (mirror, without repeating the edge row), symmetric (mirror and repeat it). Default is edge, a decent default - smeared pixels look less like a seam than a hard colour band.

Then the alpha bookkeeping, where people stop reading and start guessing. It builds a padding mask (1 where it added pixels), optionally blurs it with feathering, multiplies in whatever incoming alpha it found, and emits a mask in ComfyUI's usual inverted convention: 1 = transparent. Anything that takes a LoadImage mask takes this one.

The inputs you'll actually touch

image and multiple. multiple is 1–512, default 32 - fine for most VAE-friendly work. Drop to 8 for legacy SD1.5 habits; go to 64 on Flux, whose divisibility rule is the strict one (Flux is "flexible, must be divisible by 64"; SDXL's trained ratios are a looser story).

resize_position decides where the extra pixels land: center splits them, the four corner options dump the difference onto two sides. top-left pins the original with all the new room right and below - the one you want when extending a portrait downward. One micro-detail from the source: an odd leftover pixel goes right/bottom, not left/top.

masking (masked / not masked) sets whether the padding is transparent or opaque - and here's the trap. masking only touches alpha. The RGB pixels are whatever pad_mode produced, and VAEEncode doesn't read alpha, so a "transparent" pad is not what the sampler sees; it sees your edge smear or your constant colour. Pick pad_mode for the model, masking for the compositor.

Of the optionals, mask matters most: it takes a ComfyUI MASK (1 = transparent) and inverts it back into alpha. background_color (gray by default) is only read when pad_mode = constant. feathering softens the alpha edge but doesn't cross-fade content, so crank it and you get a band of half-transparent original pixels.

Outputs

image, mask, width, height.

image is always 4-channel RGBA, even from a 3-channel input. Most nodes slice the first three and don't care; if one complains, 🎨 Rennart RGBA to RGB sits in the same menu.

mask is the valuable one. Wire it into VAEEncode's mask input and the padded region becomes your inpaint area - the whole outpainting setup in one node, no mask painting, with plausible pixels instead of a black wall. For the "pad with red, tell the model to remove the red" trick, use pad_mode = constant with background_color = red.

width and height are the new size as INTs - feed a latent size, a filename, anything that has to agree with the canvas you just built.

Install

ComfyUI Manager → search ComfyUI-Rennart → Install → restart. Or by hand:

cd ComfyUI/custom_nodes
git clone https://github.com/Rennart2025/ComfyUI-Rennart

Restart ComfyUI. requirements.txt is literally torch and numpy, both already present in any working install - nothing to pip, no model to download. Other nodes in the pack are heavier (🧹 Rennart Denoise fetches upscale models from the author's Hugging Face repo); this one is dependency-free. MIT, parts forked from WAS Node Suite.

Where it bites

Your transparency vanished. LoadImage gives you a 3-channel image plus the alpha as a separate MASK output. The pad node can only find alpha inside a 4-channel tensor, so if you don't wire that mask into the optional mask input it assumes everything is opaque. Wire it.

Errors in Russian. Tooltips and exceptions are Russian. Размер маски ... не совпадает с изображением is just "mask size doesn't match the image" - mask dims must match the input image; a mask batch of 1 broadcasts, anything else raises.

A pad mode silently downgrades. Pad wider than the image (easy with multiple up to 512 on a small crop) and NumPy can't reflect or symmetrize. The node catches it, prints a [Rennart] ⚠️ warning to the console and falls back to edge. If your reflect padding looks like a smear, check the console.

CategoryRennart/Image

Inputs (8)

NameTypeDefaultDescription
imageIMAGE—
multipleINT321–512Кратность, до которой размеры округляются ВВЕРХ. Пример: сторона 1648, multiple=32 → 1664 (добавляется 16 px).
pad_modeCOMBOedgeРежим заполнения паддинга: • constant — сплошной цвет (см. background_color) • edge — наращивание краевых пикселей • reflect — зеркальное отражение без повтора края • symmetric — зеркальное отражение с повтором края
resize_positionCOMBOcenterКак распределяется паддинг вокруг изображения: • center — поровну • top-left — паддинг справа и снизу • top-right — паддинг слева и снизу • bottom-left — паддинг справа и сверху • bottom-right — паддинг слева и сверху
maskingCOMBOmasked• masked — паддинг прозрачный (alpha=0) • not masked — паддинг непрозрачный (alpha=1)
maskoptMASKМаска в формате ComfyUI MASK (1 = прозрачное, 0 = объект), как выход LoadImage. Нода инвертирует её в альфа-канал. Если не подана — берётся альфа-канал из RGBA-изображения (если он есть), иначе всё изображение считается непрозрачным.
background_coloroptCOMBOgrayЦвет фона. Используется только при pad_mode = constant.
featheringoptINT00–512Радиус растушёвки границы паддинга. 0 = резкая граница.

Outputs (4)

NameTypeDescription
imageIMAGE—
maskMASK—
widthINT—
heightINT—