ComfyUI Node

AQ_Image_Pad

Pad an image with transparent borders — with an RGBA caveat

By 2frames·Created about a year ago·Updated 6 months ago· 1
AQ_Image_Pad
  • image
  • IMAGE
left0
right0
top0
bottom0

Adds left/right/top/bottom padding around an image, filling the new area with transparent black. Handy for adding margins before a crop, changing aspect ratio, or reserving space for text overlays and framing - the kind of thing you do on autopilot in an image editor and wish ComfyUI did in one step. This node is that one step.

How it works

Straightforward: allocate a larger zero tensor and copy the image into the middle. But here's the honest gotcha, and it's a real one I want you to know before you hit it: the code writes an alpha channel - channel index 3 - into the padded result. That channel only exists if your input image is RGBA (4 channels). ComfyUI tensors are usually 3-channel RGB, and on those this node will crash with an index error, because there is no channel 3 to write to. This looks like a genuine bug for RGB inputs, not a feature you're missing.

Inputs

  • image - the tensor to pad.
  • left, right, top, bottom - 0 to 1000 pixels each, default 0.

Output

IMAGE - the padded result.

Install

Ships in AQnodes:

cd ComfyUI/custom_nodes
git clone https://github.com/2frames/ComfyUI-AQnodes
cd ComfyUI-AQnodes
pip install -r requirements.txt

or search "AQnodes" in ComfyUI Manager and restart.

Gotchas

The RGBA requirement above is the thing that'll trip you up. If you hit an "index 3 is out of bounds" traceback, this is why - convert to RGBA first (composite it over an alpha canvas, or load an RGBA PNG via AQ_LoadImageBase64 in the same pack, or use the core ImageToMask/alpha pipeline) and it behaves exactly as expected, with the transparent border surviving downstream alpha handling. It exists in the pack for the cover-art pipeline, where padded covers get composited onto a uniform canvas.

CategoryAQ/Image

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
leftINT00–1000
rightINT00–1000
topINT00–1000
bottomINT00–1000

Outputs (1)

NameTypeDescription
IMAGEIMAGE