Nodes/Comfy-Photoshop-SD/load image from base64 string
ComfyUI Node

load image from base64 string

How Photoshop hands ComfyUI a layer without saving a file

By AbdullahAlfaraj·Created 3 years ago·Updated 2 years ago· 319
load image from base64 string
    • IMAGE
    • MASK
    image_base64

    This is the mirror image of this pack's LoadImageWithMetaData. That node takes a file path and pushes a finished result back out through the API; this one takes raw image data in - as a base64-encoded string - and decodes it straight into the graph. No shared folder, no file path either side has to agree on, no round trip through disk at all.

    Why base64 is the right call here

    This whole pack bridges ComfyUI with the Auto-Photoshop-SD Photoshop plugin, and per the README, that bridge runs over ComfyUI's HTTP API: you export a workflow as "API Format" JSON, and the plugin fires requests at it. If the plugin wants to hand over whatever's currently on the Photoshop canvas or a specific layer, writing a temp file to a folder both sides can reach is real infrastructure - doubly so if ComfyUI is running somewhere other than the artist's own machine, which describes most cloud-hosted setups. Encoding the image as base64 text and dropping it straight into the same JSON request sidesteps all of that. This node is the ComfyUI-side half of that handoff: it decodes the string back into pixels.

    Inputs and outputs

    One input - image_base64, a plain string (not multiline, which makes sense; base64 comes out as one long unbroken line), defaulting to empty. Two outputs: IMAGE, the decoded picture, and MASK. That second output isn't something you feed it - going by how ComfyUI's own core LoadImage node behaves with the same IMAGE+MASK output pair, this is almost certainly derived from the source image's alpha channel. Send a Photoshop layer with transparency and that transparency arrives as a ready-to-use mask - genuinely convenient, since transparency-as-mask is exactly the shape a Photoshop artist already thinks in.

    Wire IMAGE wherever a source image goes - a preprocessor, a VAEEncode, this same pack's ControlnetUnit. Wire MASK into anything expecting one, keeping in mind that a couple of this pack's other nodes (MaskExpansion, ContentMaskLatent) type their own mask sockets as IMAGE rather than MASK - so double check what the next node in the chain actually expects before you connect.

    Worth knowing outside the Photoshop plugin too

    Anytime you're scripting against the ComfyUI API directly and don't want to write a file to disk first, this node does the job cleanly: base64-encode your image in your own script, drop it into the request payload, done.

    Installing it

    ComfyUI Manager: search "Comfy-Photoshop-SD", install, restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/AbdullahAlfaraj/Comfy-Photoshop-SD
    

    Where people get burned

    Base64 strings get long fast - a modest image easily runs to hundreds of kilobytes of text - so if something in front of ComfyUI (a reverse proxy, a load balancer, a request-size limit) truncates the payload in transit, you don't get a clean error, you get a corrupted decode or a cryptic failure that has nothing obviously to do with size limits. If this node is failing on images that work fine elsewhere, check for a body-size cap somewhere in the chain before you suspect the node itself. Second, make sure whatever's generating the string is sending raw base64 bytes and not a full data URI (data:image/png;base64,...) - nodes shaped like this one typically expect just the encoded payload, not the MIME-type prefix in front of it, and that prefix left in place is a common reason a perfectly valid image fails to decode.

    CategoryAuto-Photoshop-SD

    Inputs (1)

    NameTypeDefaultDescription
    image_base64STRING

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK