Nodes/ComfyUI_agilly1989_motorway/PorterDuffImageComposite_motorway_edition
ComfyUI Node

PorterDuffImageComposite_motorway_edition

Porter-Duff compositing on the bus — alpha math without the wire spaghetti

By agilly1989·Created 2 years ago·Updated about a year ago· 7
PorterDuffImageComposite_motorway_edition
  • MOTORWAY 🚌💨
  • MOTORWAY 🚌💨
INPUT_source_keysource
INPUT_source_alpha_keysource_alpha
INPUT_destination_keydestination
INPUT_destination_alpha_keydestination_alpha
modeDST
OUTPUT_IMAGE_keyIMAGE
OUTPUT_MASK_keyMASK

Porter-Duff compositing is the classic, formal way to put two images together: instead of a single "blend" mode, you get a family of operations that describe how a source and a destination combine pixel by pixel, each with its own alpha channel. SRC_OVER is the normal "paste source on top," DST keeps the destination and ignores the source, DST_OUT knocks the destination away wherever the source's alpha is, CLEAR empties the canvas, and the list goes on through MULTIPLY, SCREEN, OVERLAY, DARKEN, LIGHTEN and friends. This node exposes 18 of them.

It's the workhorse for any workflow that produces alpha channels - background removal, matting, compositing a cutout onto a scene. The community line is blunt about this: after inpainting or background removal you must actually composite your result back, or you silently degrade the image across passes. This is the node that does that correctly, because it respects fractional alpha rather than just pasting hard edges.

The bus version

This _motorway_edition rewires the stock PorterDuffImageComposite for the MOTORWAY 🚌💨 bus. Instead of four wires, you name four bus keys:

  • INPUT_source_key / INPUT_source_alpha_key (defaults source / source_alpha) - the top image and its alpha channel.
  • INPUT_destination_key / INPUT_destination_alpha_key (defaults destination / destination_alpha) - the bottom image and its alpha.
  • mode - the dropdown with the 18 Porter-Duff operations. DST is the default; SRC_OVER is the one you'll actually reach for most of the time.

Both images need real alpha channels - feed a cutout with fractional alpha, and that's where the clean edges come from. Two outputs are written back to the bus: the composited IMAGE under OUTPUT_IMAGE_key (default IMAGE), and a MASK under OUTPUT_MASK_key (default MASK) - the combined alpha, handy if you're chaining another composite.

The node's only return is the bus itself; the data lives inside it under those keys.

Install

No dependencies, no models - the pack is pure code:

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

ComfyUI Manager → search ComfyUI_agilly1989_motorway → install → restart.

The fine print

This is a beta pack whose README literally starts "IF THINGS BREAK ITS BECAUSE I BROKE IT," and the _motorway_edition clones were generated by an auto-cloner that build 1.1.7 removed - so a fresh install may not show this node at all. If you just want correct compositing and aren't committed to the bus, the stock PorterDuffImageComposite is right there in core and will never vanish on an update.

On the bus, the failure mode is the usual one: KeyError: 'hash_...' doesn't exist in motorway means a key was never stored upstream - your ramp nodes never put source, destination, or their alphas on the bus under exactly those names. And remember keys are case-sensitive and overwrite silently if reused. Getting the alpha keys right is the whole game here: composite two images that have no alpha and the result is a surprise, in the bad way.

Categoryagilly1989 Nodes/Motorway-ed/mask/compositing

Inputs (8)

NameTypeDefaultDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨
INPUT_source_keySTRINGsource
INPUT_source_alpha_keySTRINGsource_alpha
INPUT_destination_keySTRINGdestination
INPUT_destination_alpha_keySTRINGdestination_alpha
modeCOMBODST18 options: ADD, CLEAR, DARKEN, DST, DST_ATOP, DST_IN, +12
OUTPUT_IMAGE_keySTRINGIMAGE
OUTPUT_MASK_keySTRINGMASK

Outputs (1)

NameTypeDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨