FL Paste On Canvas
Center an image onto a fixed-size canvas without distorting it
- image
- mask
- bg_image_optional
- IMAGE
You need an image to land on a specific canvas size - a model that only accepts 512×512, a fixed aspect ratio for a batch job - but your source image's aspect ratio doesn't match, and you don't want to just squash it to fit. FL_PasteOnCanvas solves that: it builds a canvas at the dimensions you specify, then centers and scales your image into it while keeping its proportions intact, filling whatever's left over with a background color or image instead of distorting anything.
How it works
Set canvas_width and canvas_height for the target size, and the node scales your source image to fit inside those bounds using your choice of resize_algorithm (bilinear, nearest, bicubic, lanczos - lanczos is the sharpest for downscaling, nearest for pixel-art content you don't want smoothed) while preserving aspect ratio, then centers it. Anything not covered by the scaled image gets filled with background_red/green/blue, or with an actual image via bg_image_optional if you want a real background instead of a flat color. padding adds extra margin around the pasted content inside the canvas, shrinking it slightly further from the canvas edges. There's also an optional mask - combined with use_full_mask, this controls whether the node treats the whole source as content or respects an existing alpha/mask shape when placing it.
The inputs and outputs that matter
canvas_width,canvas_height(64–4096 px) - your target output size. This is the one thing the node guarantees regardless of input aspect ratio.resize_algorithm- pick based on content:lanczosfor photographic downscales,nearestif you need to preserve hard pixel edges,bilinear/bicubicas reasonable middle grounds.background_red/green/blueorbg_image_optional- flat color fill versus a real background image for the letterboxed area.padding(0–512 px) - extra breathing room around the centered content, shrinking it a bit further inside the canvas.show_preview- worth turning on the first time you set this up, since getting canvas size, padding, and resize algorithm all correct together benefits from actually looking at the result rather than guessing.- Output:
IMAGE- this node is marked as an output node, meaning it can also display/save directly, not just pass data downstream.
How to install it
Via ComfyUI Manager: search "ComfyUI_Fill-Nodes" and install. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/filliptm/ComfyUI_Fill-Nodes
then restart ComfyUI. Plain image-resize-and-composite math - no extra dependency for this node specifically. The pack overall is a large, general-purpose collection from filliptm, one prolific solo author, covering PDF tools, GPT/Gemini/Fal API wrappers, and a full KSampler family alongside utility nodes like this one.
Common issues & troubleshooting
Content isn't actually centered where you expected. Check padding first - it eats into the available space symmetrically, so a large padding value on a canvas that's already close to your source image's size can push the scaled content smaller than expected.
Background looks flat/plain when you wanted a real backdrop. background_red/green/blue is a solid-color fallback - you need to explicitly wire something into bg_image_optional to get an actual image behind the pasted content instead of a flat fill.
Content got cropped instead of letterboxed. Double-check you're actually looking at this node's output and not FL_PasteByMask with its keep_ratio_fill mode - that's the "crop overflow to fill" behavior; FL_PasteOnCanvas is specifically the "preserve everything, pad the rest" tool, which is a different job even though both nodes deal with fitting images together.
Pixel art looks blurry after canvas placement. Switch resize_algorithm to nearest - the smoother algorithms (bilinear, bicubic, lanczos) will soften hard pixel edges you probably want to keep crisp.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| canvas_width | INT | 51264–4096 | — |
| canvas_height | INT | 51264–4096 | — |
| background_red | INT | 2550–255 | — |
| background_green | INT | 2550–255 | — |
| background_blue | INT | 2550–255 | — |
| padding | INT | 00–512 | — |
| resize_algorithm | COMBO | 4 options: bilinear, nearest, bicubic, lanczos | |
| include_alpha | BOOLEAN | false | — |
| use_full_mask | BOOLEAN | false | — |
| show_preview | BOOLEAN | false | — |
| maskopt | IMAGE | — | |
| bg_image_optionalopt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |