Nodes/ComfyUI-Light-Tool/Light-Tool: Mask to Image
ComfyUI Node

Light-Tool: Mask to Image

The type adapter every mask workflow eventually needs

By ihmily·Created 2 years ago·Updated 4 months ago· 20
Light-Tool: Mask to Image
  • mask
  • image

ComfyUI treats MASK and IMAGE as different types, and that split is the source of a thousand red connection lines. Light-Tool: MaskToImage is the adapter that closes the gap: it takes a MASK tensor and hands you back a 3-channel grayscale IMAGE, so anything that refuses a mask can still get the data it needs.

One input: mask. One output: image.

How it works. It's almost insultingly simple: a mask is a single-channel tensor (height × width), and an image needs three channels. The node takes that one channel, expands it into three identical copies, and returns a grayscale-looking RGB image. Nothing is thresholded, rescaled, or cleaned up - a soft mask stays soft, a hard mask stays hard, and the pixel values are preserved exactly. It is a pure type conversion with zero processing, which is precisely why it's useful.

Why you'd need it. A surprising number of nodes in the ecosystem quietly require IMAGE even when they're semantically working with masks. Compositing nodes, some ControlNet preprocessors, custom packs that never bothered to accept MASK - feed them a mask and they'll reject the connection; feed them this node's output and they work. It's also the pragmatic path inside this pack: several Light-Tool "mask" nodes (InvertMask, MaskImageToTransparent, MaskBoundingBoxCropping, MorphologicalTF) actually expect IMAGE inputs, so when your data arrives as a real MASK, you route it through MaskToImage first, then into whichever image-flavored node you need. The reverse journey (ImageToMask) is the pack's other adapter, and together they let you hop between the two worlds freely.

The gotchas. Because it does no processing, whatever you feed it comes out as-is - if your mask is a noisy mess, this node won't help you fix it, it'll just faithfully display the mess as an image. And remember the output is grayscale-in-RGB-clothing: if you later need a real mask again, run it back through ImageToMask. There's no information lost in the round trip, which is the best thing you can say about a converter.

Installing. With the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/ihmily/ComfyUI-Light-Tool.git
pip install -r requirements.txt
# restart ComfyUI

Or ComfyUI Manager → search ComfyUI-Light-Tool → Install. No models, no processing cost worth mentioning.

Honest take: this is a utility you'll forget exists until the exact moment a node yells at you about types - and then it's the fastest fix in the graph. A boring node, but boring in the good way.

CategoryComfyUI-Light-Tool/image/mask

Inputs (1)

NameTypeDefaultDescription
maskMASK

Outputs (1)

NameTypeDescription
imageIMAGE