Nodes/ComfyUI-SmartImageTools/Smart Image Padding
ComfyUI Node

Smart Image Padding

Padding that doesn't fight you (or your transparency)

By slvslvslv·Created about a year ago·Updated 25 days ago· 2
Smart Image Padding
  • image
  • IMAGE
left0
right0
top0
bottom0
fillTransparent

Every so often you need to grow an image's canvas without resizing its content - add breathing room around a composition, hit a video model's required aspect ratio, or build a border. ComfyUI's core image ops can do this, but they're fiddly and they don't think about alpha. Smart Image Padding makes it one node: pick how many pixels on each side, pick what fills the new space, done.

How it works

It pads each side by the pixel counts you give it, then fills the newly created area based on the fill mode. The detail that makes it genuinely smart: it converts RGB input to RGBA first and centers the original image inside the new canvas, so your transparency is preserved and the padding region is a real alpha area rather than a black hole that shows up later in compositing.

The fill options are the interesting part:

  • Transparent (default) - the padded region is fully transparent. Best when you'll composite the padded image over something else.
  • Black / White / Grey - solid, fully opaque padding. For framing shots on a colored border or meeting a canvas size with a visible matte.
  • Stretch - this one is the hidden gem. Instead of a solid color, it replicates the image's edge pixels outward. The top rows, bottom rows, and side columns get extended, corners and all. It's the classic "edge extend" trick for filling motion blanks before video models, and it looks far more natural than a hard color bar when the padding area is small.

Inputs and outputs

  • image - the IMAGE to pad.
  • left, right, top, bottom - pixels of padding per side (0–10000).
  • fill - Transparent, Black, White, Grey, or Stretch.

Output: one IMAGE, larger by exactly the padding you asked for, always in RGBA.

Installing it

Same pack as the rest:

cd ComfyUI/custom_nodes
git clone https://github.com/slvslvslv/ComfyUI-SmartImageTools
pip install -r ComfyUI-SmartImageTools/requirements.txt

Restart ComfyUI (or use ComfyUI Manager → "SmartImageTools"). No models or keys involved.

The fine print

Because the output is RGBA, anything downstream that expects straight RGB might complain - but that's true of most of the pack, and the fix is just compositing or converting. Stretch is worth testing on your actual image before you trust it: on complex edges it can look like a smeared clone, so keep the padding modest. And remember it's canvas padding, not scaling - if you actually need the whole image resized to a target dimension, a resize node is what you want instead.

CategorySmartImageTools

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
leftINT00–10000
rightINT00–10000
topINT00–10000
bottomINT00–10000
fillCOMBOTransparent5 options: Transparent, Black, White, Grey, Stretch

Outputs (1)

NameTypeDescription
IMAGEIMAGE