Nodes/ComfyUI-SuperNodes/🐧 Pad Image Scaled
ComfyUI Node

🐧 Pad Image Scaled

Letterbox to an exact canvas β€” and get a mask of where the padding is

By sonnyboxΒ·Created 11 months agoΒ·Updated 4 days agoΒ· 12
🐧 Pad Image Scaled
  • image
  • IMAGE
  • MASK
β—„target_width1024β–Ί
β—„target_height1024β–Ί
β—„shift_horizontal0.00β–Ί
β—„shift_vertical0.00β–Ί
β—„scale_factor1.00β–Ί
β—„scale_methodnearest-exactβ–Ί
β—„color#808080β–Ί

🐧 Pad Image Scaled is the "fit it onto an exact canvas" node - and it's better than the built-in Pad Image for Outpainting at that job, because it's built around positioning instead of fixed edge padding. Give it a target width and height, and it scales your image to fit inside that frame (aspect ratio preserved, nothing cropped or stretched), then places it wherever you ask on a solid-color background. Out comes the padded image plus a mask that marks exactly which pixels are padding.

Why is that useful? Video models are resolution-mandatory - Wan, SCAIL, LTX all want specific dims, and a mismatched input just fails or silently resamples. If your source is 4:3 and the model wants a 512Γ—896 canvas, this node gives you a correct-size image and a mask of the bars so you can later tell the model to ignore or inpaint them. It's also the right tool for tiled workflows and for building collage canvases at a fixed size.

How it works

Three stages, each with its own knob:

  1. Contain-fit. The image is scaled so it fits entirely inside target_width Γ— target_height, aspect preserved.
  2. Extra shrink. scale_factor (0.1–1.0) scales it down further. At 1.0 you get a normal fill/letterbox; below 1.0 the image shrinks and you get padding on both axes, not just the short sides. Note it can only shrink - the ceiling is 1.0.
  3. Place. shift_horizontal (βˆ’1 = far left, 0 = center, 1 = far right) and shift_vertical (βˆ’1 = bottom, 0 = center, 1 = top) move the fitted image around the canvas.

The remaining inputs are scale_method (nearest-exact, bilinear, area, bicubic, lanczos) and color - the padding color as hex, e.g. #808080. Both outputs matter: IMAGE is the finished canvas, MASK is 1.0 on padding, 0.0 on the image. Wire the mask wherever you need to know where the bars are.

Installing it

Part of ComfyUI-SuperNodes (GitHub: sonnybox/ComfyUI-SuperNodes) by SuperCC. ComfyUI Manager β†’ search SuperNodes β†’ install β†’ restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/sonnybox/ComfyUI-SuperNodes
# restart ComfyUI

Only dependency is matplotlib; the pack needs a current ComfyUI (it uses the newer comfy_api extension API).

Where people get burned

The color parser is pickier than the default suggests. It accepts #RRGGBB, RRGGBB, #RGB, or RGB - anything else, including named colors like "black", silently falls back to white (the #808080 default is just what's prefilled, not a safety net). The mask is inverted from what many people guess at first: 1.0 means padding, so if you want the image region for inpainting, you need an Invert Mask. And remember scale_factor only goes down: if your image is smaller than the canvas and you want it blown up to fill, this isn't the node - it will happily letterbox it instead.

CategorySuperNodes/Image

Inputs (8)

NameTypeDefaultDescription
imageIMAGEThe input image.
target_widthINT10241–16384Final output width in pixels.
target_heightINT10241–16384Final output height in pixels.
shift_horizontalFLOAT0.00-1–1Horizontal placement: -1 = far left, 0 = center, 1 = far right.
shift_verticalFLOAT0.00-1–1Vertical placement: -1 = bottom, 0 = center, 1 = top.
scale_factorFLOAT1.000.1–1Additional scale after fitting. 1.0 = normal fill. Smaller values shrink image to create padding.
scale_methodCOMBOnearest-exactResampling method used for resizing.
colorSTRING#808080Padding color as hex (#RRGGBB, RRGGBB, #RGB, RGB). Invalid values default to white.

Outputs (2)

NameTypeDescription
IMAGEIMAGEβ€”
MASKMASKβ€”