Porter-Duff Image Composite
The compositing math node you'll use once a year — and then be glad it exists
- source
- source_alpha
- destination
- destination_alpha
- IMAGE
- MASK
Let's be honest about where this one sits in the family: it's the least-clicked compositing node in ComfyUI core, and there's a reason. PorterDuffImageComposite implements the classic Porter-Duff compositing algebra - the 1970s math that gave the world blend modes like SRC_OVER, SRC_IN, DST_OUT and XOR. If you've ever stared at a compositor's operator list and wondered what DST_ATOP means, this node is that list, in graph form.
For most people, most of the time, this is the wrong tool. Need to paste one image onto another with a mask? ImageCompositeMasked does it with two inputs and a position, and it's what you should use. Porter-Duff exists for the cases that node can't express: cutting a literal hole in an image (DST_OUT), confining a source to a region of the destination (SRC_IN), or true fractional-alpha blending where semi-transparent layers genuinely need the algebra (SRC_OVER). Those are rare. When they come up, they have no other built-in answer.
How it works. Each layer arrives as a pair: source with source_alpha, destination with destination_alpha. The node inverts both masks into alpha, premultiplies each image by its alpha (the standard trick that makes the math clean), applies the selected mode, then un-premultiplies and hands you the result. Mismatched sizes are upscaled to the destination's dimensions automatically, so you don't have to match resolutions by hand. It outputs both the composited IMAGE and the resulting MASK, the latter being the combined alpha of everything - useful if you want to feed the composite's footprint back into something else.
The inputs that matter. The mode combo box is the whole point - 18 options, from the everyday (SRC_OVER, DST_OVER, MULTIPLY, SCREEN) to the esoteric (SRC_ATOP, DARKEN, XOR). And here's the trap: the default mode is DST, which means "output the destination unchanged." Wire this node up, hit run, and nothing visibly happens - that's not a bug, that's the literal default behavior. Pick the mode first, then debug.
Where people get burned. Both layers need an alpha mask, and there's no "just paste a rectangle" path - to make a layer fully opaque you feed it a zero mask. That's two masks to keep straight, with the ComfyUI polarity convention (white = transparent) applied to each. It's enough cognitive load that you'll see people bounce off it: one user trying to fix outpainting pixel drift in r/comfyui tried this node and gave up, saying the alpha inputs "went above my head." Fair. If your actual goal is pixel-perfect outpainting - original region byte-identical, only the extension generated - the Inpaint Crop and Stitch node pair does that better and without any alpha algebra, because it never touches the unmasked pixels at all. Community signal says roughly the same thing: this node gets mentioned about twice a year on Reddit.
It ships with ComfyUI core, loads no model files, and landed in August 2024 with the rest of the compositing trio. File it under "know it exists": the day you need DST_OUT, it'll save you from installing a custom nodes pack for one operation.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| source | IMAGE | — | |
| source_alpha | MASK | — | |
| destination | IMAGE | — | |
| destination_alpha | MASK | — | |
| mode | COMBO | DST | 18 options: ADD, CLEAR, DARKEN, DST, DST_ATOP, DST_IN, +12 |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |