Nodes/ComfyUI_FunCode/Canvas Data FunCode
ComfyUI Node

Canvas Data FunCode

The boring half of the canvas duo — and that's a compliment

By kaiery·Created 8 months ago·Updated about a month ago· 0
Canvas Data FunCode
  • bg_image
  • overlay1
  • overlay2
  • overlay3
  • overlay4
  • overlay5
  • overlay6
  • overlay7
  • overlay8
  • overlay9
  • overlay10
  • canvas_data

Canvas Data FunCode does one job and does it quietly: it takes a background image plus up to ten overlay images and packs them into a single canvas_data blob that its sibling, Canvas Editor FunCode, knows how to open. You won't get a pretty preview out of this node. What you get is a clean hand-off between "images my graph produced" and "a canvas I want to arrange them on by hand."

Think of the pair as a tiny compositing pipeline: generate or load a background, generate or load a subject, wire them both into Canvas Data, run it, and the composed scene lands in the visual editor where you can drag, scale and layer by mouse before the result comes back out as a normal image. This node is the packaging step - it exists so the editor never has to know where the pixels came from.

How it works

Under the hood, canvas_data is a JSON document - don't let the custom CANVAS_DATA type scare you. Each image you connect gets serialized to a base64 PNG data URL, tagged with a contentId (a SHA-256 of the PNG bytes) so the editor can tell when a layer's content actually changed, and recorded with its width and height. The background's dimensions become the canvas size; layers are stored in order and re-sorted by slot id. Because every image is baked into the JSON, the whole scene travels through the graph as one self-contained chunk - no temp files, no path lookups.

That contentId isn't just bookkeeping. When you re-run the graph with the same image, the editor can see the content is identical and preserve the transforms (position, scale, rotation) you applied by hand instead of resetting the layer - more on that policy in the Canvas Editor article.

The inputs and output

Every input is optional, which is the node's quiet genius: you can throw just a background at it, or a background plus one overlay, or all ten.

  • bg_image - sets the canvas size and sits at the bottom of the stack.
  • overlay1 … overlay10 - up to ten layers above the background. The slot number is the layer order, so overlay1 is the bottom layer and overlay10 the top.

Output is a single canvas_data wire, which you connect straight into Canvas Editor FunCode's canvas_data input. That's the whole graph - data in, canvas out.

Installing

Same pack, same install:

cd ComfyUI/custom_nodes
git clone https://github.com/kaiery/ComfyUI_FunCode

Restart ComfyUI, and the FunCode nodes appear under the FunCode/ categories in the node menu. No model downloads, and this particular node doesn't even need the pack's one pip dependency (color-matcher) - the only thing that matters is that ComfyUI's browser frontend is running, because the canvas data ultimately lives in the JSON your graph passes around.

Gotchas worth knowing

  • A background that's bigger than you expected is a bigger canvas. The editor starts at whatever bg_image is - if you want a 2048-wide canvas, feed it a 2048-wide background (or use an Empty Latent / blank image node upstream to set the size).
  • You can skip overlays entirely, but you can't reorder them downstream - slot number is order. If your subject needs to sit above the caption, it gets the higher slot.
  • If you re-connect a different image into a slot, the editor treats it as new content and (by default) resets that layer's transform. That's the documented behavior, not a bug.

It's the least flashy node in this pack, and that's fine. Compositing is the part people re-roll generations over when they should just be dragging two layers into place.

CategoryFunCode/Canvas

Inputs (11)

NameTypeDefaultDescription
bg_imageoptIMAGE
overlay1optIMAGE
overlay2optIMAGE
overlay3optIMAGE
overlay4optIMAGE
overlay5optIMAGE
overlay6optIMAGE
overlay7optIMAGE
overlay8optIMAGE
overlay9optIMAGE
overlay10optIMAGE

Outputs (1)

NameTypeDescription
canvas_dataCANVAS_DATA