Nodes/comfyui_bmad_nodes/Load 64 Encoded Image
ComfyUI Node Runs on cloud

Load 64 Encoded Image

Turn a base64 blob into an image — no API key required — Load 64 Encoded Image

By bmad4ever·Created 3 years ago·Updated 9 months ago· 70
Load 64 Encoded Image
    • IMAGE
    image_codeinsert encoded image here

    Load 64 Encoded Image does one thing: it takes a base64-encoded image string and turns it into an IMAGE tensor. No API, no key, no network call - the name sounds like a cloud thing but it's pure local string math. It's the LoadImage node with a paste-a-string instead of a file browser.

    Why would you want that? Because base64 is the common currency for shuttling images around in text. If you're driving ComfyUI from a script or an API request, the image you want to process may arrive as a base64 string rather than a path on disk - a camera capture, an upload from a web form, a response from another service. This node is the landing pad for that string. It pairs naturally with the pack's Get Prompt node and the RequestInputs workflow toolkit: you build a workflow with a hole where the image goes, then a script fills that hole with base64 each run. It also plays with the pack's SaveImage2 node for the round trip out.

    How it works

    The implementation is a short decode chain:

    image = Image.open(BytesIO(base64.b64decode(image_code)))
    image = image.convert('RGB')
    image = np.array(image).astype(np.float32) / 255.0
    image = torch.from_numpy(image)[None,]
    

    b64decode turns the string back into bytes, PIL opens it as an image, it's converted to RGB, normalized to 0-1, and wrapped into a tensor with a batch dimension - the exact shape a normal LoadImage produces. Anything base64-encodable that PIL can open (PNG, JPEG, and friends) works, because the decoding happens before you ever look at the format.

    Inputs and outputs

    • image_code - a STRING, the base64 image data. The default is the placeholder text "insert encoded image here", which is a hint, not a working value.
    • Output: one IMAGE, ready for any downstream node.

    Install

    Part of bmad4ever/comfyui_bmad_nodes. Via ComfyUI Manager, search "comfyui_bmad_nodes" ("Bmad Nodes"), install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bmad4ever/comfyui_bmad_nodes
    cd comfyui_bmad_nodes
    pip install -r requirements.txt
    

    Restart ComfyUI after. No model files; PIL/Pillow ships with ComfyUI.

    Common issues

    The obvious one: the default placeholder text is not valid base64, so running the node as-is throws a binascii.Error ("Invalid base64-encoded string"). That's expected - replace it with real data first. To generate a base64 string on the command line:

    base64 -w0 image.png
    

    Second gotcha is the payload size. Base64 inflates data by ~33% and this node pastes the whole blob into a text field, so a huge image means a massive, ugly string and slow UI. Keep the source images modest. And note there's no validation until runtime - a malformed string fails when the graph executes, not when you paste it, so errors surface at queue time. For one-off local use, just use LoadImage; this node earns its place when the image genuinely arrives as text.

    CategoryBmad/api

    Inputs (1)

    NameTypeDefaultDescription
    image_codeSTRINGinsert encoded image here

    Outputs (1)

    NameTypeDescription
    IMAGEIMAGE