EmAySee_ Mask Guard to Image
A mask that refuses to fail — always hands you an image
- mask
- IMAGE
The "make sure we always have an image" shim
EmAySee_MaskGuard converts a MASK into an IMAGE - and if anything goes wrong, it hands you a solid black image of a size you specify instead of erroring out. That fallback is the entire point of the "Guard" in its name. You feed it a mask and it guarantees an image tensor comes out, no exceptions, which makes it the safety net for workflows where a downstream node demands an IMAGE but the mask-producing branch can come up empty (say, a detector that found nothing).
Where this matters: lots of ComfyUI consumers - previews, image compositors, some VAE-adjacent tooling - want an IMAGE and will choke or silently misbehave if handed a bare mask. If you're building a template workflow for people to reuse, wrapping the mask path in a guard node turns "crashes when the detection comes up empty" into "renders black and keeps going." It's defensive plumbing, and defensive plumbing has a real job in a graph language where one None can kill a run.
How it works
In the success path it takes the first channel of the mask, reshapes it, and replicates it across three channels so it becomes a valid RGB image tensor (white mask → white pixels, black → black). That's a literal mask-to-grayscale-image conversion. The guard part: if the mask is None or empty, or the conversion throws for any reason, it returns a 1 × height × width × 3 tensor of zeros - a black image sized by the width and height inputs.
That last bit is the subtle part: width and height only matter in the failure path. In the success path the output takes the mask's own shape, and the width/height inputs are ignored. So they're your "fallback canvas size," not a resize control.
Inputs and output
mask(MASK) - the mask to convert.width(INT, 1–8192, default 512) - fallback width when the mask is unusable.height(INT, 1–8192, default 512) - fallback height.
Output: IMAGE - the converted mask, or the black fallback.
Install
From ComfyUI_EmAySee_CustomNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
# restart ComfyUI
Or via ComfyUI Manager → "ComfyUI_EmAySee_CustomNodes". No dependencies.
Gotchas
The big one is the silent black image. Because a failed mask returns a black frame instead of an error, a detector that quietly finds nothing downstream looks like "the workflow ran fine, output is black." That's by design - the guard trades crash-diagnostics for continuity - so if you're debugging a black result, check whether a mask upstream actually produced content. Also, this is not an image-to-image tool: the mask's values map directly to brightness, so a soft-edged mask comes out as a soft-edged gray image, which is what you'd expect but worth remembering when the "image" looks washed out. The display name on the node even has a stray underscore ("EmAySee_ Mask Guard to Image") - cosmetic, but it's the kind of polish detail that tells you this pack is built by one person for their own graph.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| width | INT | 5121–8192 | — |
| height | INT | 5121–8192 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |