LayerMask: PixelSpread
Bleed edge pixels outward to kill dark halos
- image
- mask
- image
Here's a subtle-but-important one. When you cut a subject out and the masked-away area is left transparent or black, then you feather or blur the edge for a soft composite, the transition picks up whatever was under the mask - usually black - and you get a dark fringe around your subject. PixelSpread fixes that by bleeding the subject's edge colors outward into the masked region first, so when you soften the edge there's matching color there instead of black.
If you've composited cutouts and fought a persistent gray or dark rim no matter how you feathered, this is the missing step. It's the same trick compositors use - "defringe" or "extend edges" - ported into a ComfyUI node.
How it works
It reads the pixels at the mask boundary and spreads (repeats/extends) them outward into the area the mask excludes. The masked region gets filled with color pulled from the nearest subject edge rather than staying empty/black. Now any downstream feather or blur blends subject-into-subject-colored-fill, and the dark halo never appears. mask_grow lets you control how far the spread reaches.
The inputs and outputs that matter
image(IMAGE) - the image whose edges you're spreading.mask(optional MASK) - defines the region to fill from the edges. Without a mask it works on the image's own alpha/edges.invert_mask(BOOLEAN, default false) - which side of the mask is "keep" vs "fill." Flip if it spreads the wrong region.mask_grow(INT, −999 to 999, default 0) - how far the edge color pushes into the masked area. A little positive growth ensures the fill extends past where your feather will reach.
Output is a single image (IMAGE) with the edges spread - feed it into your composite/feather step.
How to install it
ComfyUI Manager → search ComfyUI Layer Style → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/chflame163/ComfyUI_LayerStyle
Restart to install requirements. No model download.
Common issues & troubleshooting
If the node's missing, that's the pack-level IMPORT FAILED problem - ComfyUI_LayerStyle not loading. Check the startup console. The usual causes across this pack: a stale install from before it split into ComfyUI_LayerStyle and ComfyUI_LayerStyle_Advanced (delete and reinstall), or a broken dependency crashing the import. Reinstall clean via Manager.
The main confusion with this node is ordering. PixelSpread has to run before you feather/blur/composite - it's prep, not cleanup. Spread the edges, then soften. Run it after and you've already baked in the dark fringe. If it seems to do nothing, check invert_mask (you may be spreading into the subject instead of the background) and give mask_grow a small positive value so the fill reaches past your feather radius. And it doesn't refine the mask edge itself - for hair-level edge quality, that's MaskEdgeUltraDetail's job; PixelSpread is specifically about killing the color contamination in the fade.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| invert_mask | BOOLEAN | false | — |
| mask_grow | INT | 0-999–999 | — |
| maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |