凤希AI - 加载Base64图片
Load an image from a Base64 string — for when your image arrives as text
- 图片
- 遮罩
- 宽度
- 高度
Sometimes the image you need never touches disk as a file. It arrives as a Base64 string - from an API response, a script, a webhook, or a paste from an external tool. ComfyUI has no built-in way to turn that text into an IMAGE tensor, so if you're building a pipeline that ingests images from outside, FxAiImageLoadBase64 is the missing adapter. Paste the string in, get a proper image out, with a mask and dimensions to boot.
It's a niche node, but it's the kind of niche that shows up constantly in API-driven workflows - feeding a reference image from a cloud service into a local ComfyUI graph, for example. The base64→IMAGE conversion is the whole game.
How it works
It takes one input, Base64 (a multiline STRING), and decodes it with Python's base64 module. One convenience detail: if your string includes a data-URI prefix - the data:image/png;base64, header that many APIs prepend - the node strips everything up to the first comma automatically, so you can paste a full data URI without cleaning it first.
What comes out depends on whether the decoded image has transparency:
- PNG with an alpha channel → the alpha becomes a proper 遮罩 (mask), and the RGB part is returned as the image.
- Anything else → the image plus an all-ones mask (fully opaque), and the mask is just there for input compatibility.
In both cases you also get 宽度 and 高度 as INTs, read from the decoded image.
Inputs and outputs
Input: Base64 (STRING). Outputs: 图片 (IMAGE), 遮罩 (MASK), 宽度 (INT), 高度 (INT). Wire the image into anything that takes an IMAGE input - ControlNet preprocessors, image-to-video, img2img, a preview.
Installing it
Part of fxai-toolkit (凤希AI, MIT). Install via ComfyUI Manager (search "fxai-toolkit") or:
cd ComfyUI/custom_nodes
git clone https://github.com/fxai666/fxai-toolkit
# restart ComfyUI
No models, no special dependencies beyond the pack's usual first-load auto-install of soundfile and psutil. Chinese labels; support via the author's QQ group (775649071) and Bilibili.
Where people get burned
Garbage in, garbage out - a malformed Base64 string raises a decode error and stops the run, so validate the string before it hits this node. Also note it does no size normalization: a 4K image comes out 4K, which can blow up VRAM downstream if you weren't expecting it. And the mask is only meaningful for images with an actual alpha channel - for everything else it's all ones, so don't build a pipeline that treats it as real transparency data. Decode-then-resize is on you.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| Base64 | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| 图片 | IMAGE | — |
| 遮罩 | MASK | — |
| 宽度 | INT | — |
| 高度 | INT | — |