Nodes/ComfyUI-TinyBee/Pad Image In Place
ComfyUI Node

Pad Image In Place

Pad an image and get it back at the same size

By TinyBeeman·Created about a year ago·Updated about a month ago· 1
Pad Image In Place
  • image
  • image
  • scale
top0
left0
right0
bottom0
padding_colorblack
scaleToOriginaltrue

Pad Image In Place adds padding around an image and - this is the "in place" part - hands it back at the original resolution. You pad, it scales the padded canvas back down so the output tensor is the same size it went in. That turns padding from a canvas-size detour into a no-op around your image, which is exactly what outpainting prep wants.

Why you'd reach for it

The classic job: you want to add margin around an image before an inpaint or composition pass, but you don't want the padding to change the image's dimensions downstream - everything after it expects the original W×H. The "in place" behavior means the node adds its padding, restores the original aspect ratio, and rescales the whole thing back to the source resolution, so the rest of your graph never notices the canvas changed. The scale output tells you the resize factor, which some inpainting pipelines want to know.

How it works

It builds a fresh canvas filled with your chosen padding_color, then blits the image at the top/left offset. With scaleToOriginal on (the default), it also computes what extra padding the opposite sides need to keep the original aspect ratio after your requested pad - so if you pad only the bottom, it balances the top so the final canvas isn't stretched weirdly - then bilinear-resizes the whole thing back to the source size and reports the scale factor (original width ÷ padded width). With scaleToOriginal off, you get the raw padded canvas and scale = padded width ÷ original width instead.

The colors available: black, white, Neutral (a mid-gray #7f7f7f - the value inpainting models conventionally expect), and Clear (transparent, which only matters if your image has an alpha channel).

The inputs that matter

  • image - the source IMAGE.
  • top / left / right / bottom - pixels of padding per side, 0 to 100000. All default 0.
  • padding_color - black, white, Neutral, or Clear.
  • scaleToOriginal - on by default; off to keep the padded size.

Two outputs:

  • image - padded (and by default rescaled) IMAGE.
  • scale - the FLOAT resize factor: original width ÷ final width.

Installing it

TinyBee pack: ComfyUI Manager → Install Custom Nodes → search "ComfyUI-TinyBee", install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/TinyBeeman/ComfyUI-TinyBee

Under 🐝TinyBee/Images. Uses torch and PIL, both already present.

Common issues

The "Neutral" option is the one people overlook - if your inpaint results come back with dark or light seams around the border, the padding color was probably wrong for the model, and mid-gray is the conventional safe choice. Also watch the aspect-ratio balancing: with scaleToOriginal on, your requested padding isn't the final padding - the node adds compensation on the opposite sides, so the output won't show your exact top/bottom/left/right values. If you need pixel-exact padding without rescale, turn scaleToOriginal off. And "Clear" only shows transparency if your image carries an alpha channel; on a plain RGB image it behaves like black.

Category🐝TinyBee/Images

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
topINT00–100000
leftINT00–100000
rightINT00–100000
bottomINT00–100000
padding_colorCOMBOblack4 options: black, white, Neutral, Clear
scaleToOriginalBOOLEANtrue

Outputs (2)

NameTypeDescription
imageIMAGE
scaleFLOAT