Nodes/ComfyUI Layer Style/LayerUtility: ExtendCanvas
ComfyUI Node Runs on cloud

LayerUtility: ExtendCanvas

ExtendCanvas — pad an image outward and get an outpaint-ready mask

By chflame163·Created 3 years ago·Updated 5 days ago· 3,113
LayerUtility: ExtendCanvas
  • image
  • color
  • mask
  • image
  • mask
â—„invert_masktrueâ–º
â—„top0â–º
â—„bottom0â–º
â—„left0â–º
â—„right0â–º

Step one of the classic outpainting recipe, in a single node: place the original image on a bigger canvas and get back a mask marking exactly which part is new. That's literally the first move in any masked outpainting workflow - pad the frame, then let a sampler or an editing model fill the empty area - and this node does the padding cleanly instead of you assembling it from generic image-pad nodes.

It's also handy outside outpainting proper: adding letterboxing/margin around an image for layout purposes, or building a canvas with room to composite something else in later (the accompanying mask output tells any node downstream exactly where the new, blank space is).

How it works

You give it top/bottom/left/right pixel amounts and a fill color. The node grows the canvas by those amounts on each side, fills the new area with color, and returns both the padded image and a mask flagging which pixels are original versus newly added. That mask is the whole point - hand it to an inpaint or outpaint-capable sampler and it knows precisely what to regenerate versus what to leave alone.

The inputs and outputs that matter

  • top / bottom / left / right (default 0, up to 99999) - how many pixels to add on each side. Leave a side at 0 and that edge doesn't move.
  • color (default #000000) - the fill for the new area. The exact value rarely matters for outpainting since it usually gets fully regenerated, but it's worth knowing this pack takes a COLOR type here rather than the hex string most other LayerStyle color fields use.
  • invert_mask (default true) - flips which side of the output mask counts as "new."
  • image - the source you're extending, and optional mask if you want to merge in an existing mask rather than starting fresh.

Outputs: the padded image, and the companion mask marking the newly added region - feed that straight into whatever fills it.

How to install it

Ships with the ComfyUI Layer Style pack. ComfyUI Manager - search ComfyUI Layer Style, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
pip install -r ComfyUI_LayerStyle/requirements.txt

then restart. Lives under 😺dzNodes → LayerUtility. No models needed.

Common issues & troubleshooting

The generated extension looks obviously pasted-on, with a visible seam. That's not this node - it's the fill/regeneration step after it. The community's standing advice for masked outpainting applies here too: give the mask generous overlap into the original image, blur the mask edge, and consider more than one pass at decreasing denoise strength rather than expecting one shot to blend perfectly.

Extension direction is wrong, or nothing seems to change. Double-check you're padding the side you meant to - top/bottom/left/right are independent, and it's easy to pad the wrong axis when you're working quickly. If the whole thing looks like it did nothing, confirm at least one of the four isn't left at its default of 0.

Downstream node treats the new area as part of the original instead of something to fill. Check invert_mask - the output mask's polarity needs to match what your sampler or inpaint node expects for "regenerate this," and this pack's default doesn't always match every consumer's convention.

Node's not in your list. Pack import failure, not this node - LayerStyle's dependency chain is long, and transformers paired with a stray TensorFlow install is the classic way the entire pack fails to load together. Check the startup console or hit "Try Fix" in Manager.

Category😺dzNodes/LayerUtility

Inputs (8)

NameTypeDefaultDescription
imageIMAGE—
invert_maskBOOLEANtrue—
topINT00–99999—
bottomINT00–99999—
leftINT00–99999—
rightINT00–99999—
colorCOLOR#000000—
maskoptMASK—

Outputs (2)

NameTypeDescription
imageIMAGE—
maskMASK—