Base64图片加载
Paste an image into ComfyUI as base64 text
- IMAGE
- MASK
LamLoadImageBase64 takes an image that's been encoded as a base64 string and turns it into a proper ComfyUI IMAGE (plus a MASK from the alpha channel). It's a niche tool, but when it's the right tool it's the only tool: no file on disk to point at, just a blob of text you got from an API, a database, or someone's paste.
When would you actually hit this? Mostly automation. You're scripting ComfyUI through its API, you have an image in memory from some upstream step, and rather than writing it to input/ and hoping the path resolves, you base64 it into the workflow. Or you're pulling an image out of a tool that returns base64 and you want it inside the graph without a detour through the filesystem. The display name is honest: "Base64图片加载," load a base64 image.
How it works
It decodes the base64 string, opens it with PIL, and splits out the alpha channel if present. The RGB image becomes the IMAGE output; the alpha channel becomes a MASK where the image is transparent (inverted, in ComfyUI's mask convention where white = opaque region to keep... well, it's 1.0 - alpha). No alpha channel? You get a blank 64×64 mask rather than an error.
Inputs and outputs
- image (required) - the base64 string, pasted directly into the field. No data URI prefix, just the raw base64 payload.
- IMAGE - the decoded image, ready to wire into any sampler or image node.
- MASK - the transparency map, if the source had an alpha channel. Wire it into masking/inpainting nodes when you need it.
Install
Part of the ComfyUI_Lam pack:
cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam
or via ComfyUI Manager (search ComfyUI_Lam), then follow the README's install + 修改文件 steps. No models needed for this node - it's pure Pillow.
Gotchas
The field is single-line and not multiline, so a big base64 string is one long wall of text in the node - ComfyUI handles it, but it's ugly and easy to fat-finger. A truncated or corrupted base64 string throws a decode error, so paste carefully. And remember: if the source image has no alpha, the MASK is a dummy 64×64 zero tensor, not a real mask - don't wire it into mask-dependent nodes expecting transparency information. If you have a file path or URL instead of a blob, LamLoadPathImage in the same pack is the better pick.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| image | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |