ComfyUI-Pixel-Locker
ComfyUI custom nodes for preserving masked pixels while sampling.
Nodes (4)
The mask prep node that keeps your inpaint from looking painted
Where exact RGB preservation actually happens
The convenience node that fuses decode and restore into one
A KSampler that actually keeps what you told it to keep
ComfyUI Pixel Locker
ComfyUI custom nodes for preserving masked pixels while sampling.
Nodes
- MaskBuilder: Converts a base
MASKinto aPIXEL_LOCK_MASKwith three non-overlapping areas:hard_keep: pixels that must be preservedsoft_keep: boundary pixels that may change slightlyfull_edit: pixels that may change freely
- PixelLockSampler: KSampler-style inpaint sampler that starts from the original latent and adds noise only to editable mask regions.
- PixelLockComposite: Final image-space composite. This is the node that guarantees exact RGB preservation in
hard_keep. - PixelLockDecodeComposite: Convenience node that decodes a sampled latent and immediately applies the final pixel composite.
Recommended Workflow
- Build a
PIXEL_LOCK_MASKwith MaskBuilder. - Run PixelLockSampler instead of the built-in KSampler.
- Decode and restore pixels with PixelLockDecodeComposite.
PixelLockSampler protects structure in latent space. PixelLockComposite is required for absolute pixel preservation because VAE encode/decode is not lossless.
For better performance, connect a VAEEncode of the original image to PixelLockSampler's optional original_latent input. Otherwise connect original_image and vae; PixelLockSampler will encode the original image only when the lock mask has an active hard or soft area.
When replacing clothing or other large regions, start with edit_strength around 0.75-0.9. PixelLockSampler does not use an incoming empty/base latent; it always starts from original_latent or an encoded original_image, then denoises only full_edit and soft_keep according to the mask strengths.
Mask Semantics
MaskBuilder supports two base mask modes:
preserve_mask: white means preserve.edit_mask: white means edit.
Boundary modes:
centered: soft band is created both inside and outside the preservation edge.inward: soft band is only inside the preserved region.outward: soft band is only outside the preserved region.
Installation
Place this folder in ComfyUI/custom_nodes/ComfyUI-Pixel-Locker, then restart ComfyUI.