Extend Canvas By Percentage
Pad the canvas outward — and get a mask that tells your inpaint exactly where the new pixels are
- image
- mask
- image
- mask
Extend Canvas By Percentage is the outpaint-prep node of the ComfyUI-Image-Resizing pack, and the reason is hidden in the second output. Yes, it pads your image out on any side with a fill color. But it also hands you a mask that marks exactly where the new pixels are - which is precisely what an inpaint workflow needs to know, in the right polarity, with an optional feathered edge.
The standard outpainting recipe goes: pad the canvas, then run inpainting only over the new area. Without a node like this, you're building that mask by hand. This node gives you the padded image and the mask from the same set of numbers, so they can never drift out of sync.
How it works
Inputs are top, bottom, left, right - interpreted as percentages of each side by default, or as raw pixels when you flip use_pixels on. color fills the new border, given as a hex string like #7f7f7f or as comma-separated RGB like 127,127,127. There's an optional mask input (it'll use your image's alpha channel if you don't supply one), a feather value that blurs the output mask's edge, and invert_mask - defaulting to true.
That default is the smart part. The output mask comes out white where the new border is and black over the original image, which is exactly the polarity an inpaint node wants: the mask says "regenerate this region." If you'd rather have the mask mark the original content instead, flip invert_mask off.
What to actually set
For a typical outpaint run:
- Pick your border sizes. 10–25% per side is a sane starting point; more than that and the model has to invent a lot of scene.
- Leave the default mid-gray
#7f7f7ffill. Most modern models handle a neutral gray better than pure black for fill - pure black can read as "shadow" and pollute the inpaint. - Set feather to something small (5–15) so the mask edge isn't a hard line and the inpaint blends across the seam instead of stopping at it.
- Wire the mask output straight into your inpaint/mask-input node, then re-run only that region.
If you're padding to hit an aspect ratio rather than outpaint - say your target template needs 4:5 and your image is 1:1 - this works too: pad, and use the image output by itself. Just remember the border is filled with whatever color you set, and a gray border is visible in the result; pick black if you plan to auto-trim it later (the pack's RemovePadding will happily strip it).
One thing to know: feather only softens the mask, not the image. It's a blend aid for inpainting, not a blur on your pixels. And the padding is a straight fill - the node won't stretch or mirror your image's edge pixels into the border. That's your inpaint's job.
Install
Standard small-pack story: ComfyUI Manager (search "ComfyUI-Image-Resizing") or clone it yourself:
cd ComfyUI/custom_nodes
git clone https://github.com/Zar4X/ComfyUI-Image-Resizing
Restart, and it's under Image Resizing/Extend Canvas. No models, no downloads - just the usual torch/Pillow/numpy/OpenCV stack you already run.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| invert_mask | BOOLEAN | true | — |
| use_pixels | BOOLEAN | false | — |
| top | INT | 00–10000 | — |
| bottom | INT | 00–10000 | — |
| left | INT | 00–10000 | — |
| right | INT | 00–10000 | — |
| feather | INT | 00–100 | — |
| color | STRING | #7f7f7f | — |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |