🎈TransformData From String
Program a canvas layout from a JSON string
- transform_data
The star of the LAOGOU pack is FastCanvas - a node that lets you drag, scale, rotate, and flip image layers on an actual canvas, and outputs a combined image with masks. It's great to use, and terrible to reproduce: a layout you spent ten minutes dragging is gone the moment you clear it, and you can't version-control a mouse.
TransformDataFromString is the flip side: it builds a canvas layout from JSON text instead of mouse clicks. Paste in a scene description - background size plus a transform per layer - and out comes a TRANSFORM_DATA object that FastCanvas can consume. Dragged layouts become something you can save, share, edit, or generate programmatically.
How it works
The node takes one multiline string, parses it with json.loads, and hands the resulting dict to anything that accepts the custom TRANSFORM_DATA type. The default value shows the exact schema it expects:
{
"background": {
"width": 1024,
"height": 768
},
"1": {
"centerX": 512,
"centerY": 384,
"scaleX": 1.0,
"scaleY": 1.0,
"angle": 0,
"flipX": false,
"flipY": false,
"width": 256,
"height": 256
}
}
Each numbered key is a layer - the canvas width/height define its base size, and centerX/centerY position it on the background while scaleX/scaleY, angle, and flipX/flipY transform it. Because it's just text, you can generate this from a script, an LLM, another node, or a saved JSON file.
Input:
- json_string - the multiline JSON scene description.
Output:
- transform_data - the parsed
TRANSFORM_DATAobject, ready to wire into the canvas nodes.
The trap nobody mentions
If the JSON fails to parse, the node does not throw an error. It prints a message to the console and returns an empty dict {} - silently. Your workflow keeps running, and your layers just… do nothing, with no red node to tell you why.
This is the kind of silent failure that eats an evening. If you're generating JSON programmatically, validate it before feeding this node, or at least check the console output after a run. A missing comma, a trailing comma (JSON hates those), or a stray quote and you're shipping empty transform data.
When it's worth it
- You want a reproducible, shareable canvas layout - save the JSON, reload it later.
- You're generating layouts programmatically (a script or an LLM describing a scene).
- You need fine numeric control - snapping
centerXto exactly 512 by hand on a canvas is misery; typing it is instant.
Installing it
Part of Comfyui_LG_Tools - Manager (search "Comfyui_LG_Tools") or:
cd ComfyUI/custom_nodes
git clone https://github.com/LAOGOU-666/Comfyui_LG_Tools.git
pip install -r requirements.txt
Restart, then right-click → 🎈LAOGOU → Canvas. If you don't use FastCanvas, you have no use for this node - it exists purely as the text-interface companion to it.
Troubleshooting
- Layers do nothing - almost certainly bad JSON silently turning into
{}. Check the console ([TransformDataFromString] JSON 解析错误) and validate the string. - Keys don't match - the schema above is the contract. Extra keys are ignored, missing keys get defaulted by whatever consumes the data; matching the documented shape keeps things predictable.
- It's not an image node - no image in, no image out. It only produces layout data.
Niche, but if you've ever wished you could git diff a canvas composition, this is how you get there.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| json_string | STRING | { "background": { "width": 1024, "height": 768 }, "1": { "centerX": 512, "centerY": 384, "scaleX": 1.0, "scaleY": 1.0, "angle": 0, "flipX": false, "flipY": false, "width": 256, "height": 256 } } | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| transform_data | TRANSFORM_DATA | — |