Nodes/ComfyUI_agilly1989_motorway/JoinImageWithAlpha_motorway_edition
ComfyUI Node

JoinImageWithAlpha_motorway_edition

Turn an image + mask into a real RGBA PNG, via keys

By agilly1989·Created 2 years ago·Updated about a year ago· 7
JoinImageWithAlpha_motorway_edition
  • MOTORWAY 🚌💨
  • MOTORWAY 🚌💨
INPUT_image_keyimage
INPUT_alpha_keyalpha
OUTPUT_IMAGE_keyIMAGE

JoinImageWithAlpha_motorway_edition wraps the core node that combines an image with a mask to produce a true RGBA image - the kind with a real alpha channel, so it saves as a transparent PNG instead of a flat rectangle. The pipe twist: both inputs come from Motorway keys and the combined image goes back into the pipe.

When you need an actual alpha channel

Plenty of workflows never touch transparency: you generate, you save, you're done. But the moment you're cutting a subject out - background removal, product shots, overlays - you need alpha that's part of the image data, not a separate mask file sitting next to it. JoinImageWithAlpha is the node that stitches the two together: your RGB image plus your mask become one IMAGE tensor with four channels, which is what an RGBA PNG actually is. The KB's background-removal essay is worth a read here because it sets the expectation for the mask side: a hard segmentation mask gives you a hard-edged cutout, while matting models give fractional alpha that survives veils, hair and glass. This node doesn't care which you feed it - it just joins them. A hard mask makes a hard cutout; soft alpha makes a soft one. Choose your masker accordingly.

Note this node's output is still the same IMAGE type as any other image - it's just that "IMAGE" now carries four channels instead of three. A normal SaveImage will write the PNG with transparency, and downstream image nodes generally keep working because RGBA images are still images.

The motorway wiring

Two keys in, one key out:

  • INPUT_image_key (default "image") - the RGB image.
  • INPUT_alpha_key (default "alpha") - the mask/alpha to join.
  • OUTPUT_IMAGE_key (default "IMAGE") - where the RGBA result lands.

Only output is the MOTORWAY 🚌💨, so to actually save the PNG you read the IMAGE key back through a Motorway AxB ramp and feed it into a plain SaveImage. If you're coming from a segmenter or background-remover whose mask is under a different key than "alpha", point INPUT_alpha_key at whatever key the mask actually lives under - this is the field people most often forget to update.

Install and the honest caveats

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

Restart ComfyUI, or install via ComfyUI Manager. No extra deps, no model downloads - this is a channel-stacking operation.

The pack-wide reality check applies fully: one-maintainer beta, README's "IF THINGS BREAK ITS BECAUSE I BROKE IT" is literal, and the current repo HEAD has the _motorway_edition registration commented out, so a fresh clone may not expose this node at all. The 'MotorwayClass' object has no attribute 'hash_' error means a key you referenced was never written to the pipe - for a two-input node, check that both "image" and "alpha" actually exist upstream before you suspect the node itself. And the honest recommendation: if compositing RGBA is the only motorway-ed thing you need, the stock JoinImageWithAlpha is the same code without the pipe.

Categoryagilly1989 Nodes/Motorway-ed/mask/compositing

Inputs (4)

NameTypeDefaultDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨
INPUT_image_keySTRINGimage
INPUT_alpha_keySTRINGalpha
OUTPUT_IMAGE_keySTRINGIMAGE

Outputs (1)

NameTypeDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨