Edit Mask from image input 🦾
Edit the file, not the tensor
- image
- image_update
- image
- mask
If you've ever tried to hand-mask something inside ComfyUI and given up after five minutes of fighting a brush widget, this node is for you. Edit Mask from image input takes the opposite approach: instead of making you paint inside the browser, it hands you a file, you edit it in whatever image editor you're actually good at, and it turns the result back into an image plus a mask.
The workflow it's built for is classic hand-inpainting prep: pull a subject out, paint its alpha channel in Krita/GIMP/Photoshop, save as PNG, and feed it back. This node closes the loop without you ever converting tensors by hand.
How it works
Under the hood it's cleverer than it looks. On each run the node hashes your input image to detect whether it's a new image. If it hasn't changed, and you've fed back an edited file, it re-reads that file and uses it as the source. The mask comes from the image's alpha channel - inverted, so the pixels you painted as opaque become the mask region (in ComfyUI convention, black = keep, white = paint-over). If the file has no alpha channel at all, you get an all-zero mask and the image as-is.
The image_update input is not a normal socket. It's a custom IMAGE_FILE widget that the pack's web extension registers - you use it to push your edited copy of the saved temp file back into the node. That's the whole trick: the node writes a temp PNG, you edit that PNG, the widget hands it back, and out come clean image and mask tensors.
The inputs that matter
image(required) - the IMAGE tensor you want to edit. Whatever you'd feed a Save Image node works here.image_update(optional) - the IMAGE_FILE widget where the edited file comes back in. This is your hand-painted PNG with the alpha channel.
Outputs:
image- the (possibly edited) image as a tensor.mask- derived from the alpha channel of that file, inverted to ComfyUI convention.
This is an output node, so you get a preview right on it, which is handy for checking your paint job before it feeds the sampler.
Install
This node ships in the ComfyUI-Beyond_nodes pack. Easiest route is ComfyUI Manager - search "Beyond_nodes" (or "Beyond Nodes") and install, then restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/beyondprompting/ComfyUI-Beyond_nodes
Then restart ComfyUI. There's no requirements.txt to fight with - the pack only needs torch, numpy and PIL, which ComfyUI already has. One stale-README warning: the repo's Setup section still says to clone the old erosDiffusion/ComfyUI-enricos-nodes URL. Ignore it; clone the Beyond_nodes URL above.
Common issues
- Blank mask? Your file has no alpha channel. A JPG can't carry one - resave as PNG with transparency.
- Mask looks backwards. The node inverts alpha deliberately, matching ComfyUI's black-keeps convention. If your results invert, flip your paint job, or invert the mask downstream with a standard Invert Mask node.
- The node ignores your edit. It only re-reads
image_updatewhen the input image hash is unchanged. If you've swapped the input, re-feed the edited file after. - Node not loading. On very old ComfyUI builds the pack's newer nodes fail to import. Update ComfyUI; the startup log prints "Failed loading …" if something didn't load.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| image_updateopt | IMAGE_FILE | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |