Nodes/Display Image with Mask for ComfyUI/🖼️ Display Image with Mask
ComfyUI Node

🖼️ Display Image with Mask

The preview node that turns your mask into real transparency

By orion4d·Created about a year ago·Updated about a year ago· 0
🖼️ Display Image with Mask
  • image
  • mask
  • processed_image
  • mask_out
image_url
mask_url
invert_maskfalse
save_imagefalse
save_path
filenameDisplayWithMask
add_datetimetrue

The name undersells it. 🖼️ Display Image with Mask sounds like a fancy previewer, and sure, it previews - but the part people actually grab it for is that it applies the mask to the image as a real alpha channel and shows you the result with true transparency, instead of the grayscale blobs you get out of most mask nodes.

Think about how you debug a masking workflow today. You've got a matting pass (BiRefNet or whatever you use) spitting out a MASK tensor, and the only way to check it is to stare at a gray image or feed it into a viewer that shows white-on-black. This node solves that: white in the mask is opaque, black is fully transparent, and you see the image with the cutout baked into its alpha. It's the "is my subject actually cut cleanly, or did I lose the hair strands" check, in one step.

How it works

The mechanism is straightforward, and it's all grounded in the source. The node grabs an image from an IMAGE tensor or an image_url (it downloads with requests, 10-second timeout), converts it to RGBA, then takes your mask - from a mask tensor or a mask_url - converts it to grayscale, and applies it via putalpha. One subtle behavior worth knowing: if you set a URL, it wins over the noodle. Feed both image and image_url and the URL is what gets processed.

Two size-related things happen before the mask is applied:

  • If the mask is a different size than the image, it's centered, not stretched - no distortion, but also no auto-fit. A smaller mask just floats in the middle with transparent padding around it.
  • The mask is always converted to grayscale, so a color mask won't produce weird results.

There's an invert_mask toggle that flips it (black becomes opaque) before it hits the alpha channel.

Here's the trap, and I want you to hear it: the node has two outputs - processed_image (IMAGE) and mask_out (MASK) - but the IMAGE output strips the alpha and returns plain RGB. The transparency lives in the preview and in files saved through the node, not in the output wire. If you need the actual transparent PNG, you use the node's built-in saving, not the processed_image output. The mask_out output is the alpha channel extracted back out - handy if you want to pipe a centered or inverted mask into something else.

The inputs that matter

Everything is optional, which is a little unusual - you can fire this thing with nothing attached and get a 512×512 transparent placeholder. The inputs you'll actually touch:

  • image / image_url - the main image. Plug a noodle or paste a URL (jpg, png, webp, avif all work).
  • mask / mask_url - the mask. Note the schema types it as IMAGE, but the loader also accepts MASK tensors, so you can plug a mask output straight in.
  • invert_mask - flips opaque/transparent.
  • save_image, save_path, filename, add_datetime - the saving quartet. Turn it on, give it a subfolder inside output (or an absolute path), and it writes filename_YYYYMMDD-HHMMSS.png. Datestamps avoid overwrites; if you turn add_datetime off it falls back to _1, _2… instead.

Install

Tiny pack, tiny footprint. ComfyUI Manager can find it as "Display Image with Mask for ComfyUI", or:

cd ComfyUI/custom_nodes/
git clone https://github.com/orion4d/ComfyUI_image-display
cd ComfyUI_image-display
pip install -r requirements.txt

Then restart ComfyUI and it appears under utils/display. Its one real dependency is pillow-avif-plugin - that's what enables .avif support for the whole session (which is also why the node mentions fixing native LoadImage avif hiccups). No models to download, no weights, nothing heavy.

Gotchas

  • The alpha-stripping output I already flagged - that's the one that bites people. The preview and the saved file show the cutout; the IMAGE output doesn't.
  • URL takes priority over the tensor input. If things look like they're loading the wrong image, that's why.
  • If you see the console warning that requests isn't installed, URL loading won't work - but that's rare, since ComfyUI bundles it. pip install requests fixes it if it ever bites.
  • The preview is written to ComfyUI's temp folder with a fresh UUID filename each run, so you won't get stale-cache previews when you change the mask.

For a quick "is this cutout any good" check, it's hard to beat. It's not a replacement for a real compositing pipeline - it doesn't resize masks to fit, and its IMAGE output discards the alpha it works so hard to create - but as a previewer-plus-saver for mask work, it does the job with basically zero setup.

Categoryutils/display

Inputs (9)

NameTypeDefaultDescription
imageoptIMAGE
image_urloptSTRING
maskoptIMAGE
mask_urloptSTRING
invert_maskoptBOOLEANfalse
save_imageoptBOOLEANfalse
save_pathoptSTRING
filenameoptSTRINGDisplayWithMask
add_datetimeoptBOOLEANtrue

Outputs (2)

NameTypeDescription
processed_imageIMAGE
mask_outMASK