Nodes/was-node-suite-comfyui/Image to Latent Mask
ComfyUI Node Runs on cloud

Image to Latent Mask

Turn a picture into a mask for inpainting

By WASasquatch·Created 3 years ago·Updated about a year ago· 1,812
Image to Latent Mask

      You've got an image - a black-and-white cutout, a painted-white region, an alpha channel, whatever - and you need it as a MASK so a sampler can use it to inpaint or blend. That conversion is the entire job of this node. Image goes in, mask comes out.

      This sounds trivial until you're deep in an inpainting graph and realize your "mask" is actually an IMAGE and the KSampler wants a MASK, and the two are different types that won't connect. Masks in ComfyUI are a single-channel thing; images are three or four channels. Image to Latent Mask bridges that gap.

      Why you'd reach for it

      Inpainting is the technique that turns generation from "hope for the best" into "fix exactly this spot," and the whole thing hinges on a good mask - the region the model is allowed to repaint while everything else stays put. Plenty of ways produce a mask as an image: you painted one in Photoshop and loaded it, you thresholded a photo into pure black/white, you pulled the alpha off a PNG, or a depth/segmentation node handed you a grayscale map. All of those are images. To feed them into the masked latent path, you convert.

      It's the plumbing step between "I have a picture that represents where to work" and "the sampler now knows where to work."

      How it works

      The node reads your image and pulls a single channel out of it to use as the mask's intensity - white (high value) means "included in the mask," black means "excluded," and grays give you partial, feathered coverage. Which channel it reads is selectable, which matters more than it sounds: if your mask lives in the alpha channel of an RGBA image, you tell it to read alpha; if it's a white shape on black in RGB, you read one of the color channels. Pick the wrong channel and you get a blank or inverted mask.

      The inputs and outputs that matter

      • image - the picture holding your mask data.
      • channel - which channel to interpret as the mask (red, green, blue, or alpha). This is the setting people get wrong. If your output mask is empty, this is the first thing to check.

      The output is a MASK, which drops straight into the mask socket of a Set Latent Noise Mask, a VAE Encode (for Inpainting), or any node that masks a region. From there the denoise strength dial decides how hard the model reworks the masked area.

      Installing it

      Part of WAS Node Suite. ComfyUI Manager: search WAS Node Suite, install, restart. Or:

      cd ComfyUI/custom_nodes
      git clone https://github.com/WASasquatch/was-node-suite-comfyui
      

      then install requirements.txt against your ComfyUI Python and restart.

      Common issues

      Empty or inverted mask? Wrong channel, almost always. A white-on-black mask lives in the color channels; a cutout's transparency lives in alpha. Try the other channel before assuming the node is broken. If you need the mask flipped, WAS has a Mask Invert node for that.

      The mask edges are harsh. This node converts what you give it faithfully - it won't soften anything. If you want feathered edges (and for inpainting you usually do, 4–12px of blur to avoid hard seams), run the resulting mask through a blur/gaussian mask node afterward.

      The whole node vanished. That's the pack, not this node. WAS Node Suite is retired (no active maintenance since late 2023) and its dependency pins collide with ComfyUI updates, producing an "Import Failed" that takes down every WAS node at once. Reinstall the pack's requirements against the correct ComfyUI venv (or run the bundled install.bat) and it comes back.

      Worth knowing: in modern 2026 inpainting, the trend is toward keeping unmasked pixels bit-identical by compositing only the masked region back (the Inpaint Crop-and-Stitch pattern). This node just makes the mask - how you apply it is where you avoid degrading the rest of the frame.

      Categoryx

      Inputs (0)

      No inputs

      Outputs (0)

      No outputs