Nodes/RC Image Compositor/RC Canvas Padding
ComfyUI Node

RC Canvas Padding

Add breathing room to any image, four ways

By kj863257·Created 11 months ago·Updated 10 months ago· 16
RC Canvas Padding
  • image
  • IMAGE
top50
bottom50
left50
right50
fill_modecolor
fill_color_r0
fill_color_g0
fill_color_b0
background_alpha1.00

Sometimes you don't want to resize the image at all - you want to give it a frame. A white border for a gallery post, a transparent margin so a drop shadow has room, an edge-repeated strip so a texture tiles seamlessly. RC Canvas Padding does exactly that: it grows the canvas by the margins you specify, in any of four fill styles, and it can even crop by using negative padding.

It's a utility node from the RC Image Compositor pack, and it's the one you'll reach for constantly once you start compositing, because every time a layer effect needs room or a final image needs a border, this is the cleanest way to get it.

How it works

You set independent top, bottom, left, and right padding in pixels. Positive values add canvas, negative values crop from that side - so you can, say, add a 100px caption bar at the bottom while trimming 10px of junk off the top. Then you pick a fill_mode:

  • color - fill with a solid RGB color. Default black, so remember to set it.
  • edge - extend the edge pixels outward. This is the one for seamless tiling: the border becomes a copy of the image's own edges, so it butts up perfectly against the neighboring tile.
  • mirror - reflect the image content into the padding, a Photoshop-style mirrored border. Looks fancier than edge-fill and great for "wrap the content around" frames.
  • transparent - RGBA-only, fills with alpha. The padding shows as transparency, which is what you want before compositing.

The background_alpha slider (default 1.0) sets the fill's opacity; drop it below 1 and the node outputs an RGBA image even in color mode - handy for building a semi-transparent overlay panel.

The inputs that matter

  • image - input tensor.
  • top / bottom / left / right - padding in pixels, negative crops.
  • fill_mode - the four-way choice above.
  • fill_color_r/g/b - fill color, 0–255 (note: 0–255 here, not the 0–1 floats used by RC Canvas Resize - an easy mixup if you switch between them).
  • background_alpha - fill opacity; <1 forces RGBA output.

Output is a single IMAGE tensor.

How to install it

Ships with the RC Image Compositor pack:

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

Restart ComfyUI, or install via ComfyUI Manager by searching "RC Image Compositor". Dependencies are just pillow, numpy, and opencv-python.

Common issues

The two usual confusions: transparent mode on an RGB image won't produce visible transparency (the image has no alpha channel to be transparent into - you need an RGBA input or a mode that forces RGBA), and background_alpha below 1.0 in color mode silently converts your output to RGBA, which can break downstream nodes that expect 3-channel input. If a compositor downstream suddenly complains, that's why.

Also worth knowing the sibling split: this node is for padding around a fixed image. If you want to place the image within a new, larger canvas at a specific spot, RC Canvas Resize does that with its anchor system. Padding and resize look similar, but one moves the image and one doesn't - grab the right tool.

CategoryRC/Utilities

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
topINT50-8192–8192Top padding in pixels (negative values crop from top)
bottomINT50-8192–8192Bottom padding in pixels (negative values crop from bottom)
leftINT50-8192–8192Left padding in pixels (negative values crop from left)
rightINT50-8192–8192Right padding in pixels (negative values crop from right)
fill_modeCOMBOcolorFill mode: - color: Fill with solid color - edge: Extend edge pixels - mirror: Mirror edge content - transparent: Transparent fill (RGBA only)
fill_color_rINT00–255Fill color red component (0-255)
fill_color_gINT00–255Fill color green component (0-255)
fill_color_bINT00–255Fill color blue component (0-255)
background_alphaFLOAT1.000–1Background alpha/opacity (0.0=fully transparent, 1.0=fully opaque). Values <1.0 will output RGBA format.

Outputs (1)

NameTypeDescription
IMAGEIMAGE