β» Bitmap XOR
Keep only what lives in exactly one bitmap
- BITMAP
- BITMAP2
- BITMAP
Bitmap XOR is the weird one of the boolean trio, and weird is exactly why it's useful. Where AND keeps the overlap and OR keeps the union, XOR keeps everything that's in exactly one of the two inputs - white where the inputs disagree, black where they agree. If you've ever diffed two images to find what changed, that's XOR, and in the DPaint pack it's a tiny region-isolation tool.
The mental model: XOR = "the difference." You have a bitmap of a full shape and a bitmap of a cutout region; XOR hands you the shape minus the cutout. You have two overlapping stars and you want the bands where they don't overlap - XOR. You're comparing a mask before and after an edit and want to see the delta - XOR again. It's the node for "show me where these two things are different," which comes up more often than you'd think once you start composing guides.
How it works
A pixel-wise logical_xor over two one-bit images (Pillow ImageChops.logical_xor). In boolean terms, output is white when (a AND NOT b) OR (NOT a AND b) - a 1 only when the two inputs differ. Because the inputs are binary, there's no ambiguity about "how different" a pixel is; it either differs or it doesn't. As with the other logical ops, mismatched input sizes crop to the smaller image, so the result takes the smaller bitmap's dimensions.
There's also a sneaky second use: Draw Shape As Bitmap has a draw_mode of xor that toggles pixels as shapes overlap during rendering - that's the same boolean at the draw stage, great for checkerboard-style patterns where overlapping cells should cancel rather than stack. This node is the standalone version for combining already-rendered bitmaps.
Inputs and outputs
- BITMAP - the first bitmap.
- BITMAP2 - the second bitmap.
Output:
- BITMAP - the XOR (difference) result.
Installing
From the Dream Painter pack (comfyui-dream-painter, alt-key-project). ComfyUI Manager β Install Custom Nodes β search Dream Painter β install β restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/alt-key-project/comfyui-dream-painter
cd comfyui-dream-painter
pip install -r requirements.txt
No models, no downloads.
Common issues
The gotcha is the same as the other combiners: the smaller input wins the size battle, so XOR two mismatched bitmaps and you get the smaller result - resize first if the size matters. And keep in mind XOR is "different," not "subtract in the painting sense": areas where both inputs are white come out black, which surprises people the first time. If your mental model was "shape minus cutout," remember the cutout itself also disappears from the result. That's correct XOR behavior, not a bug.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| BITMAP | BITMAP | β | |
| BITMAP2 | BITMAP | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BITMAP | BITMAP | β |