Nodes/ComfyUI-TD/LoadTDImage
ComfyUI Node

LoadTDImage

The reverse bridge that feeds TouchDesigner content into ComfyUI

By JiSenHua·Created 2 years ago·Updated 5 days ago· 164
LoadTDImage
    • IMAGE
    • MASK
    image

    Every other node in the ComfyUI-TD pack points one way: ComfyUI generates, TouchDesigner displays. LoadTDImage is the one that goes the other direction. It takes a base64 image string sent from TD - typically a TOP converted and shipped by the ComfyUI2TD.tox component - and turns it into an IMAGE (plus a MASK) that you can feed into the rest of your ComfyUI graph. It's a reworked version of Acly's Load Image (Base64) from comfyui-tooling-nodes.

    This is the node that makes the loop interactive instead of just one-way. A webcam running in TD can feed frames into an img2img pipeline in ComfyUI; the result streams back through ImagetoTD; TD composites it and sends the next frame. That feedback loop - TD captures reality, ComfyUI transforms it, TD shows it - is the actual killer app of this pack, and it doesn't exist without this node.

    How it works

    LoadTDImage receives a base64-encoded image string, decodes it, and opens it with PIL. It converts to an RGB float tensor ([1, H, W, 3], normalized to 0–1) and - matching how ComfyUI's own Load Image behaves - derives a mask from the alpha channel, inverted so opaque areas are mask 0 and transparent areas are mask 1. An image with no alpha gets an all-zero mask. You get both sockets out.

    One behavior worth knowing: if the decode fails, it doesn't crash your graph. It prints an error and returns a default 64×64 black image with an empty mask, so a bad base64 silently feeds garbage rather than stopping the run.

    The inputs and outputs

    • image - the required STRING input, holding the base64 payload sent from TD. It's a single-line string widget; in practice it's fed by the tox, not typed by hand.
    • IMAGE - the RGB tensor output, ready for anything downstream.
    • MASK - the alpha-derived mask output, same conventions as ComfyUI's standard image loader.

    Install

    ComfyUI Manager search ComfyUI-TD, or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/JiSenHua/ComfyUI-TD.git
    

    Restart. Dependencies (trimesh, imageio-ffmpeg, soundfile, plyfile) install with the pack. The ComfyUI2TD.tox component from the repo's tox folder (v5.1.x+) is what actually captures the TOP, encodes it, and feeds this node.

    Gotchas

    Because it swallows errors, the failure mode is sneaky: the graph runs fine but every frame is a 64×64 black square, and you won't get a hard error to grep. When that happens, check the ComfyUI console - the node logs the decoded shape (Image shape: ...) on every successful load, so if that print is missing or shows the fallback, the base64 never arrived or wasn't decodable. Also remember the mask convention: TD images usually arrive without alpha, so expect a zero mask unless you deliberately ship an RGBA TOP with transparency.

    CategoryTouchDesigner

    Inputs (1)

    NameTypeDefaultDescription
    imageSTRING

    Outputs (2)

    NameTypeDescription
    IMAGEIMAGE
    MASKMASK