Load Image with Background
Load a transparent PNG and choose what shows behind it
- image
- mask
- image_path
Stock ComfyUI's Load Image treats a transparent PNG as whatever it happens to be - usually flattening it to black in the preview and feeding you an RGB image where the transparency just reads as a color you didn't ask for. This node is a rework of the official Load Image with one addition that's easy to underestimate: a background_color dropdown that composites your transparent image over the color you choose, so you can actually see and use it.
It's from the same family as the pack's "Load Images For Loop with Background" - same color options, same compositing logic - but for a single image with the familiar Load Image widget.
How it works
It's the standard Load Image path (EXIF handling, multi-frame support, mask extraction) with a check inserted: if the image has an alpha channel (or a palette transparency) and background_color isn't default, it composites the image over a solid RGB fill - white, black, gray, red, green, blue, or yellow. default behaves like stock Load Image.
Two nice extras over the official node: it still returns the image's mask (the inverted alpha), so you can keep working with transparency in-graph even though the image itself is flattened, and it returns the absolute path of the loaded file as a string, which is handy for filename-based logic.
Inputs and outputs
- image - pick from ComfyUI's
inputfolder (upload supported), exactly like the official node. - background_color - the dropdown.
default, or one of the six colors plus gray.
Outputs: image (flattened RGB), mask, image_path (absolute path string).
Install
Standard pack install - ComfyUI Manager (search "ComfyUI-AutoFlow") or:
cd ComfyUI/custom_nodes
git clone https://github.com/ZXL-Xinram/ComfyUI-AutoFlow
Restart after. No models or extra packages; it uses ComfyUI's own folder_paths and node_helpers.
Where people get burned
- Forgetting the mask is inverted. Like every ComfyUI loader, the returned mask is
1 - alpha(white = masked/transparent area). If you're feeding it to a compositing or inpainting node expecting a selection of the subject, flip it. defaultdoes nothing special. If you pickdefaulton a transparent image you get stock behavior - which for a transparent PNG is often black-ish pixels in the preview. That's expected, not a bug. Pick a real color to composite.- The output is flattened. After compositing you no longer have an RGBA image, only the mask. If you need the raw alpha channel preserved for later, grab it before this node.
This is a small quality-of-life node, and it's most valuable in a workflow where you've cut something out (BiRefNet, a matting pass) and want to eyeball it against a neutral background before compositing it into a scene.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMBO | 1 options: example.png | |
| background_color | COMBO | default | 8 options: default, white, black, gray, red, green, +2 |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| image_path | STRING | — |