ComfyUI exchanges images via the filesystem. This requires a
multi-step process (upload images, prompt, download images), which
invites a whole class of potential issues you might not want to deal with.
It's also unclear at which point those images will get cleaned up if ComfyUI is used
via external tools.
Load Image (Base64)
Loads an image from a PNG embedded into the prompt as base64 string.
Inputs: base64 encoded binary data of a PNG image
Outputs: image (RGB) and mask (alpha) if present
Load Mask (Base64)
Loads a mask (single channel) from a PNG embedded into the prompt as base64 string.
Inputs: base64 encoded binary data of a PNG image
Outputs: the first channel of the image as mask
Send Image (WebSocket)
Sends an output image over the client WebSocket connection as PNG binary data.
Inputs: the image (RGB or RGBA), supports batches
This will first send one binary message for each image in the batch via WebSocket:
12<PNG-data>
That is two 32-bit integers (big endian) with values 1 and 2 followed by the PNG binary data. There is also a JSON message afterwards:
Loads an image or mask that has been uploaded previously into the workflow.
Uploaded images are temporarily stored in RAM rather than written to disk. This
method has less overhead compared to embedding images as base64 into the prompt,
but is more complex to implement.
Inputs: id of an image that was uploaded previously
Outputs: image (RGB) and mask (A of RGBA input, or first channel if no alpha present).
To upload an image, upload the bytes of a PNG via a HTTP PUT request to
/api/etn/image/{id}. JPEG or other formats also work. Choose any id which
does not clash with other images you upload, and reference it in the node. The
request returns 201 if the image was uploaded and 200 if it was already
cached.
Save Image to Cache
Stores an output image in RAM temporarily and allows retrieval over HTTP.
This is typically faster than WebSocket, especially for large images.
Inputs: the image (RGB or RGBA). Batches are supported.
This node will send a JSON message over WebSocket when an image is ready:
To download the images, send a HTTP GET request to /api/etn/image/{id} with
the image IDs from the message. Images will be cached for a few minutes.
Regions
These nodes implement attention masking for arbitrary number of image regions. Text prompts only apply to the masked area.
In contrast to condition masking, this method is less "forceful", but leads to more natural image compositions.
Regions Attention MaskWorkflow: region_attention_mask.json
Background Region
This node starts a list of regions. It takes a prompt, but no mask. The prompt is assigned to all image areas which are not
covered by another region mask in the list.
Define Region
Appends a new region to a region list (or starts a new list). Takes a prompt, and mask which defines the area in the image