Nodes/ComfyUI-Pixel-Locker/PixelLockComposite
ComfyUI Node

PixelLockComposite

Where exact RGB preservation actually happens

By Bogyie·Created 4 months ago·Updated 4 months ago· 0
PixelLockComposite
  • original_image
  • generated_image
  • pixel_lock_mask
  • image
boundary_strength0.35

Here's the uncomfortable truth about all the clever latent-space work: it can't give you pixel-exact preservation. VAE encode/decode is lossy, so no amount of latent locking reproduces the original RGB perfectly after a decode. That's why this node exists. PixelLockComposite is the one place in the pack that guarantees exact pixels, and it does it the blunt way - it pastes the original back over the top.

If MaskBuilder is the map and PixelLockSampler is the engine, this is the paint. It takes your original image and your freshly generated image, and it stamps the original pixels back down everywhere the mask says they must stay. The community's loudest inpainting lesson - always composite your result back over the original, because every VAE round trip degrades pixels you never touched - is enforced here as the entire point of the node.

The inputs

Only four, and two of them are the images:

  • original_image - the untouched source image.
  • generated_image - the sampler's output, decoded. Feed it from a VAEDecode of PixelLockSampler's latent, or skip a step and use PixelLockDecodeComposite instead.
  • pixel_lock_mask - straight from MaskBuilder.
  • boundary_strength (default 0.35) - how much of the original survives in the soft_keep band. Keep it the same as the sampler's boundary_strength so the latent lock and the final composite agree on the feather width.

Output is a single image, ready for a preview or save.

How it works

From the source: it computes an alpha of hard_keep + soft_keep × boundary_strength, blends the generated image toward the original by that alpha, then does a hard, unconditional replacement in the hard_keep zone. That last step is the important one - inside hard_keep the output is bit-for-bit the original, regardless of what boundary_strength says, because it's a straight torch.where paste. soft_keep gets the proportional blend, which is what makes the transition look feathered instead of cut.

The trap: matching resolution

This node refuses to guess. If original_image and generated_image don't share the same height and width, it raises a ValueError telling you to resize or crop first - because pixel preservation is meaningless across different resolutions. This is the failure mode you'll actually hit: your sampler ran at a different native size than the source, you decode, and the composite yells at you. Resize or crop so the geometry matches, then composite. Don't be tempted to stretch the original to fit; keep both at the source resolution.

Install

Same as the rest of the pack: ComfyUI Manager → search ComfyUI-Pixel-Locker, or git clone https://github.com/Bogyie/ComfyUI-Pixel-Locker into ComfyUI/custom_nodes/, then restart. No models to download, no extra dependencies - this node is a few lines of torch on top of core ComfyUI.

CategoryPixel Locker

Inputs (4)

NameTypeDefaultDescription
original_imageIMAGE
generated_imageIMAGE
pixel_lock_maskPIXEL_LOCK_MASK
boundary_strengthFLOAT0.350–1

Outputs (1)

NameTypeDescription
imageIMAGE