YKImagePadForOutpaint
Pad the canvas, get the mask for free
- image
- IMAGE
- MASK
Outpainting - extending an image past its own edges - is really two chores wearing a trench coat. First you have to give the image a bigger canvas, which in ComfyUI means padding it with blank space. Second you have to tell the model exactly which of those new pixels are new: paint them white in a mask and keep the original black. YKImagePadForOutpaint does both at once, which is why it's the only node you need to reach for on that side of the workflow. Feed it an image, say "add 512 on the right, 256 on the bottom," and it hands you a padded image and a matching mask that marks every empty pixel as "generate here."
How it works is gloriously uncomplicated, because the source is a single short function. It builds a new tensor of zeros (black) that's your image plus the padding you asked for on each side, then drops the original pixels into the middle. In parallel it builds a mask that starts all white - the whole border is up for grabs - and then blacks out the original image area. The only subtlety is feathering, which I'll get to, because that's where the seam-vs-blend decision happens.
The inputs that matter
- image - your input, the thing being extended.
- left / top / right / bottom - padding per side, 0 to 4096, and here's the detail worth noticing: they step in multiples of 64. That's deliberate. Your latents live in a downsized space and SD-family models behave better when the total canvas lands on 64-aligned dimensions. Just accept the snapping.
- feathering - 0 to 4096, step 1. At 0 you get a hard mask edge: the model regenerates the border and the original is completely protected, full stop. Set it to something like 16–64 and a band along the inside edge of your original image becomes partially masked, with a smooth squared falloff from the border inward. That overlap is exactly what kills the "pasted on" seam problem - the model can blend the new content into the old pixels instead of landing a hard boundary. One quirk from the source: if feathering is bigger than half your image's height or width, the node quietly ignores it and falls back to the hard edge. Rare, but it will confuse you for a minute.
Both outputs matter. IMAGE is the padded canvas; MASK is the white-where-to-fill map. The canonical wiring: IMAGE → VAEEncode, then mask and latent into SetLatentNoiseMask → KSampler at high denoise (0.8–1.0, the extension is almost entirely new content) → VAEDecode. Because the mask protects the original region during sampling, the pixels you started with survive - which, per the KB's inpainting essay, is the one thing the 2026 instruction-editing models (Qwen-Image-Edit, Flux 2 Klein) can't promise you. If you want to outpaint something that must survive byte-for-byte, this masked route is still the answer.
Installing it
The pack has no requirements.txt at all - it's pure torch, which ComfyUI already ships. Easiest path: ComfyUI Manager → Install Custom Nodes → search "yk-node-suite" and install. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/guoyk93/yk-node-suite-comfyui.git yk_node
Then restart ComfyUI. That's the entire install; there are no model files to download, which is the nice thing about a utility node versus one that drags in a checkpoint.
Troubleshooting
Seams showing up in your extension? That's the feathering knob doing its job - raise it. Content bleeding into your original image? Lower it, or drop to 0 for a hard protected edge. If the mask looks wrong in your preview, remember the convention: white = regenerate, black = keep, and this node outputs exactly that. And if you're on a modern edit model, know the community's current trick - padding with a flat color and prompting the model to remove it (the "pad 200px red, prompt away the red" move) - is a different family of technique that doesn't need this node. This one is for the masked, deterministic route. It's not flashy, but it's honest: black padding, a correct mask, no dependencies, and it has been sitting unbothered in one pack since early 2023 because there wasn't much left to fix.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| left | INT | 00–4096 | — |
| top | INT | 00–4096 | — |
| right | INT | 00–4096 | — |
| bottom | INT | 00–4096 | — |
| feathering | INT | 00–4096 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |