LayerUtility: ExtendCanvas V2
Extend Canvas V2 (Layer Style)
- image
- mask
- image
- mask
Extend Canvas V2 grows your image outward - add pixels to the top, bottom, left, or right - and hands you a mask of the newly added area. That mask is the whole reason you'd use it, because it's exactly what an outpainting workflow needs: the extended canvas becomes the new picture, and the mask tells the sampler "fill this fresh margin, leave the original alone." If you want to turn a portrait into a landscape, add sky above a subject, or give a cramped composition room to breathe, this is the setup node.
The mechanism is pure canvas geometry, no model. It pads the image by the amounts you specify on each side, fills that new border with a chosen color, and generates a mask marking the added region versus the original. Feed the extended image and its mask into an inpaint/outpaint sampler (KSampler with a VAE encode for inpainting, or a dedicated outpaint node) and the model paints only the new space.
The inputs that matter:
image- the picture to extend.top/bottom/left/right- how many pixels to add on each side. These are the core controls; set the sides you want to grow. (They accept negatives too, which crops that side instead of extending it.)color- the hex fill for the new area (default#000000). It gets painted over during outpainting, so the exact color rarely matters, but a neutral gray sometimes helps the model.invert_mask- flips which region the mask marks. Whether the added area reads as white or black depends on what your downstream inpaint node treats as "the part to fill," so this toggle is how you match its convention. If your outpaint fills the wrong region, flip this first.
Optionally, a mask input lets you carry an existing mask through the extension so it stays aligned with the resized canvas.
Two outputs: the extended image and the mask of the new area. The image goes to your VAE encode / sampler; the mask goes to the inpaint conditioning. That pairing is the outpaint.
The single most common mistake here is the mask polarity - people extend the canvas, run the sampler, and the model regenerates the original subject while leaving the new margin blank, or vice versa. That's invert_mask not matching your sampler's expectation. Toggle it and re-run before assuming anything else is wrong. Beyond that, extend in reasonable increments; asking a model to invent a huge blank margin in one shot tends to produce mush, so add a few hundred pixels at a time and iterate.
Install comes 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, then pip install -r requirements.txt in the ComfyUI environment and restart. No model download for this node.
The pack-wide caveat holds: Layer Style is big and dependency-heavy, and its recurring failure is the whole pack showing "import failed" in the Manager (typically a transformers version conflict), which removes every node - Extend Canvas V2 included - from your menu at once. If it's not there, the pack didn't import; reinstall it, use "Try Fix," and reinstall requirements into ComfyUI's real environment if it sticks.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| invert_mask | BOOLEAN | true | — |
| top | INT | 0-99999–99999 | — |
| bottom | INT | 0-99999–99999 | — |
| left | INT | 0-99999–99999 | — |
| right | INT | 0-99999–99999 | — |
| color | STRING | #000000 | — |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |