Fill Image @Liam
Pad onto a solid-color canvas instead of stretching
- image
- IMAGE
- width
- height
This is the "letterbox" node in the pack. Give it an image plus a target width and height, and it centers your image on a solid-colored canvas of that size - padding the edges instead of squashing or cropping. That's a genuinely common need: models and workflows that demand a fixed input resolution (a square latent, a specific aspect ratio, a grid layout) don't care about your source proportions, and resizing alone would distort them. Padding preserves the image and fills the rest with whatever color you choose.
It's the cousin of core Pad Image for Outpainting, but simpler: no mask semantics, no outpainting smarts - just paste-on-background, and you pick the background color.
The inputs that matter
image- the IMAGE to place.width/height- canvas size in pixels (0 to 16384, default 1024×1024).red/green/blue- the fill color, 0–255 each. The default is white (255,255,255), which is fine for most cases and gives you a clean canvas for compositing.alpha- background opacity, 0–255. Default 255 (opaque). This only matters if something downstream is actually reading the alpha channel.
Outputs are the new IMAGE plus width and height as integers - the actual dimensions of the result, handy if you're feeding them into an Empty Latent or a resolution calculator and want to keep everything in sync automatically.
How it works
The mechanism is a straight PIL operation: create an RGBA canvas of the target size filled with your color, paste the source image centered on it, and convert back to a tensor. No scaling, no cropping, no content-aware anything. Note the asymmetry: if the source is smaller than the canvas it gets padded; if it's larger on either dimension, the node just returns the original image unchanged.
Installing it
Part of LiamUtil:
cd ComfyUI/custom_nodes
git clone https://github.com/ai-liam/comfyui-liam
pip install -r requirements.txt
or install via ComfyUI Manager (search LiamUtil) and restart. Only dependency is opencv-python.
Where people get burned
The silent "returns the original" behavior is the trap. Set your canvas smaller than the source and the node won't scale down - it'll hand you back the big image and you'll wonder why your resolution target wasn't met. Either pick a canvas larger than the input or add an explicit resize in front. Second, the output is RGBA-flavored; if your pipeline ignores alpha it's invisible, but if you composite onto another layer with alpha enabled, the alpha input is doing real work - leave it at 255 unless you want transparency. And because it pads rather than stretches, the filled areas are dead flat color; if your model reads the whole canvas as content, you're generating a white-bordered image, which is usually what you want for a clean source but worth knowing before you wire this straight into img2img.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 10240–16384 | — |
| height | INT | 10240–16384 | — |
| red | INT | 2550–255 | — |
| green | INT | 2550–255 | — |
| blue | INT | 2550–255 | — |
| alpha | INT | 2550–255 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| width | INT | — |
| height | INT | — |