ComfyUI Node

OutpaintCanvasTool

Pull your canvas state into the graph

By taabata·Created 3 years ago·Updated 2 years ago· 259
OutpaintCanvasTool
    • IMAGE
    • IMAGE
    • IMAGE
    seed0

    This node is the ComfyUI-side half of the pack's separate canvas app. OutpaintCanvasTool reaches over to a Flask server (the CanvasTool folder in this repo) and pulls the current canvas state - the image you're editing, the mask you've painted, and a reference image - into ComfyUI as tensors. It's how you get an interactive paint-outside-the-box outpainting loop instead of hand-drawing masks in an image editor and dragging them in.

    It's not a node that generates anything. It's a bridge: you paint in the canvas app, this node fetches what you painted, the rest of the graph turns it into a generation, and a save node (SaveImage_Canvas) pushes the result back to the app so it can display it.

    How it works

    The canvasopen function makes an HTTP GET to http://{LISTEN}:{CANVASPORT}/getSharedData - it reads the LISTEN and CANVASPORT environment variables for host and port. The server responds with JSON containing image, mask, and reference arrays; each is decoded from JSON, converted to a numpy array, exif_transposed, normalized to 0–1, and wrapped as an IMAGE tensor. The only required input is seed (default 0), which is there for API symmetry - the canvas state is what actually matters.

    The inputs and outputs that matter

    Input:

    • seed - an INT, default 0. Not really used by the fetch logic; it's required by the schema.

    Outputs - three IMAGEs and a STRING:

    • IMAGE (first) - the canvas image.
    • IMAGE (second) - the mask you painted.
    • IMAGE (third) - the reference image.
    • STRING - a file path for the reference. Wire the images into an inpaint generate node (image + mask), and the string into LoadImageNode_LCM if you need a reference loaded by path.

    How to install it

    The pack install is standard, but this node has an extra, separate step. First the pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/taabata/LCM_Inpaint-Outpaint_Comfy
    cd LCM_Inpaint-Outpaint_Comfy
    pip install -r requirements.txt
    

    Or ComfyUI Manager → "LCM_Inpaint_Outpaint_Comfy". Then, per the README, set up the canvas server:

    cd ComfyUI/custom_nodes/LCM_Inpaint_Outpaint_Comfy/CanvasTool
    python setup.py
    

    That copies server.py into your ComfyUI root and index.html into web/ - yes, it modifies ComfyUI's own server and web files. You'll need the LISTEN and CANVASPORT environment variables set to wherever the canvas app runs, and the server started.

    Common issues

    This is the fiddliest part of the whole pack, no two ways about it. The node reads environment variables that nothing sets for you - unset, they raise a KeyError the moment the node runs. The setup.py overwrites files in your ComfyUI install, which is invasive and easy to forget about when ComfyUI updates. And there's a hardcoded Linux path lurking in the node's return value (/home/mohammad/reference.png - the author's own machine), which on Windows, or any other user, is just wrong; it's the kind of thing that makes this node feel like a personal tool the author shipped rather than a product. The canvas loop works when it's set up, and it's genuinely nice for outpainting, but budget some time for the plumbing.

    Categorysd

    Inputs (1)

    NameTypeDefaultDescription
    seedINT00–18446744073709550000

    Outputs (3)

    NameTypeDescription
    IMAGEIMAGE
    IMAGEIMAGE
    IMAGEIMAGE