Mask To Base64 Image
Hand a raw MASK back to your API as a PNG
- mask
- base64Images
This is the more common of the pack's two mask-to-base64 nodes, because most of the time a mask inside your graph is ComfyUI's native MASK type - the direct output of SAM, an alpha-channel extraction, a paint tool - not something you've already rendered as a visible image first. MaskToBase64Image takes that MASK directly and converts it into a base64-encoded PNG your API can hand straight back to whoever called it.
How it works
Same convention as every base64 node in this pack: it's marked as an output node, so the result doesn't just sit on a wire - it also rides out in the run's websocket message under a base64Images key with a matching base64Type, tagged (per the pack's README) with imageType=["mask"] so a client parsing the response knows it's looking at a mask, not a photo.
The inputs and outputs that matter
mask(MASK) - the mask to encode.base64Images(STRING) - the resulting base64 string.
Where you'd actually use it
The natural spot for this is the end of a segmentation pipeline - after SamAutoMaskSEGS or RleToMask (both in this pack), or any mask you built by hand inside the graph - where the caller wants to see or store the mask itself, not just use it internally for compositing further downstream.
How to install it
Via ComfyUI Manager: search comfyui-easyapi-nodes, install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/lldacing/comfyui-easyapi-nodes.git
cd comfyui-easyapi-nodes
pip install -r requirements.txt
Restart ComfyUI. No models needed for this node.
Common issues & troubleshooting
If you actually have an IMAGE - a mask someone already rendered visually, rather than a native MASK - this node will reject it on type. That's MaskImageToBase64's job instead; the two nodes exist as a matched pair for exactly this input-type split.
Watch memory on long-running instances. As with every base64 node here: the strings live in ComfyUI's execution history, and the default cap is 10,000 entries. If you're generating a lot of these, dial it down under Settings → [EasyApi] Maximum History Size rather than letting it grow unbounded.
A batch of masks and a single base64 output can be a mismatch worth checking. mask can carry more than one mask at once depending on what fed it, but the output here is a single base64Images string - if you're expecting one base64 image per mask in a batch, confirm what actually comes back rather than assuming a 1:1 mapping, especially the first time you wire this into a multi-mask pipeline.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| base64Images | STRING | — |