Image_expand_canvase_visual
Drag the canvas edges out, get an outpaint mask for free
- image
- image
- pad_mask
The outpainting trick that's taken over from painting an extension mask by hand is almost embarrassingly simple: put your image on a bigger canvas filled with a flat color, then either mask that new region for a classic inpaint pass, or - with a modern instruction-editing model - just tell it in the prompt to "fill in what's behind the padding." One workflow that circulates for Flux Klein does exactly this: pad each side with 200px of flat red, then prompt "remove the red paddings on the side and show what's behind them." Either route needs a node that builds the padded canvas and hands back a mask marking exactly what's new - that's this node, with drag handles instead of typed-in numbers.
How it works
width/height (both default 2048) set the target canvas size. expand_state - a small JSON object tracking left/right/top/bottom - is driven by dragging handles directly on the node rather than typing four numbers. constant_color (white/black/red/gray/edge) fills the new area; "edge" stretches the border pixels instead of a flat fill, which avoids an obvious seam if you're not deliberately using a flat color as an instruction-model cue.
The inputs and outputs that matter
width/height(default 2048 each) - target canvas dimensions.constant_color(default"black") - fill for the newly added area, or"edge"to extend the border pixels instead.expand_state- the drag-driven left/right/top/bottom offsets, stored as JSON.image(optional) - what gets placed on the new canvas.- Output:
image(the expanded canvas) andpad_mask(marks the newly added region - feed this straight into whatever inpaint or outpaint sampling step follows).
is_output_node is true, so it previews its own result inline - part of the same 2026-03-22 visualization batch as the pack's other _visual nodes.
How to install it
Via ComfyUI Manager: search ComfyUI-Apt_Preset, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
Windows: install.bat. Linux/Mac: pip install -r ComfyUI-Apt_Preset/requirements.txt in your venv. Restart. Nothing to download for canvas math - the pack's heavier dependencies belong to other parts of this ~300-star, actively maintained pack.
Common issues & troubleshooting
Output just repeats the flat pad color instead of generating into it. This node only builds the canvas and the mask - it doesn't generate anything itself. Check that pad_mask is actually wired into your sampling step; a disconnected mask means nothing downstream knows where the new region is.
Using a flat color for an instruction-model prompt trick and it's not cooperating. An uncommon color works better than white or black, which a model might read as an intentional part of the image rather than filler to remove - that's the logic behind the flat-red-padding trick mentioned above. If you're doing a classic masked inpaint instead, "edge" is usually the safer default since it gives the model a plausible-looking extension to build on rather than an obvious hard color.
Drag handles not registering. expand_state only updates from actual interaction with the node's widget - changing width/height alone won't move the left/right/top/bottom offsets; you need to drag the handles themselves for those to change.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 20481–8192 | — |
| height | INT | 20481–8192 | — |
| constant_color | COMBO | black | 5 options: white, black, red, gray, edge |
| expand_state | STRING | {"left":0,"right":0,"top":0,"bottom":0} | — |
| imageopt | IMAGE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| pad_mask | MASK | — |