VAE Encode for Inpaint w/Padding (WLSH)
One padding dial instead of a settings puzzle
- pixels
- vae
- mask
- LATENT
This is the pack's take on a node ComfyUI already ships natively - VAE Encode (for Inpainting) - simplified down to the one knob that actually matters for most people: how much padding to give the masked region before it hits the sampler. The README describes it plainly: "a combined node that takes an image and mask and encodes for the sampler. Can apply some padding/blur to improve inpainting behavior." That padding is not cosmetic - it's the difference between a clean blend and a visible seam.
Why padding matters here. When you inpaint, the model is denoising inside a masked region while treating everything outside it as fixed. If the mask's edge is razor-sharp with zero buffer, the boundary between "generated" and "untouched" pixels has nowhere to blend, and you get a hard, visible line. Padding the mask - expanding it slightly beyond the region you actually want changed, with the edge softened - gives the model room to blend its output into the surrounding context instead of stopping dead at a hard boundary. This is the same principle behind "only masked" inpainting's padding recommendation in general Stable Diffusion practice: crop a region, add generous buffer around it, and you get cleaner edges than a tight, unpadded mask every time.
Inputs: pixels (your source image), vae (the VAE to encode with - needs to match your checkpoint), mask (the region to inpaint), and mask_padding (default 24, range 6-128) - the one dial this node exposes in place of core ComfyUI's separate padding-related settings. Bump it up if your inpaints are coming out with visible seams; a smaller value keeps the change more tightly confined to exactly the masked pixels, at the cost of less room to blend.
Output: LATENT - feed it straight into your KSampler alongside your usual model, positive, and negative conditioning, same as any other VAE-encode-for-inpaint output.
Installing it
ComfyUI Manager: search "wlsh_nodes" or "WLSH Nodes", install, restart. Manual: cd ComfyUI/custom_nodes && git clone https://github.com/wallish77/wlsh_nodes, then restart ComfyUI.
Common issues
This node pairs naturally with this pack's own Outpaint to Image (WLSH), which hands you an IMAGE and MASK ready to feed straight in here - if you're outpainting, that's the intended chain: outpaint, encode with padding, sample at a high denoising strength, decode. If your inpaint or outpaint results still show a visible edge after using this node, the fix is almost always to raise mask_padding rather than fight it downstream - a padding value too small for how much the region actually needs to change is the single most common cause of a seam, and it's cheaper to fix here than by adding extra passes later. On the flip side, pushing mask_padding unnecessarily high on a small, precise fix (a single blemish, a small detail correction) can pull in more surrounding context than you want and let the change bleed further than intended - match the padding to the size of what you're actually trying to fix, not just the maximum the slider allows.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | — | |
| vae | VAE | — | |
| mask | MASK | — | |
| mask_padding | INT | 246–128 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |