String Encode Panel Layout
Freeze a Comic Layout as a Line of Text
- layout
- STRING
bmad_StringEncodePanelLayout does one thing: takes a panel layout (the abstract tree of cuts this pack lives on) and serializes it into a compact string. It's the flip side of String Decode Panel Layout - encode turns a PANEL_LAYOUT into text, decode turns text back into a PANEL_LAYOUT. Together they're the pack's portable, image-free way to move layouts around.
Why you'd bother
Because the alternative - Save Panel Layout - stores the layout inside a PNG's metadata. That's fine when you're saving a finished page, but it's clunky when you want to reuse a page structure. Encode gives you something you can drop into a text file, a workflow comment, or a STRING constant in your graph, and it survives anything. Two genuinely good uses:
- Freeze a generated layout. The pack has Random Panel Layout Generator and Grid Panel Layout Generator for when you want variety - but "variety" means your page structure changes every run. Encode the result you actually like, paste it into a Text node feeding String Decode, and you've made the layout stable without keeping an image.
- Share a layout without the artwork. A layout string is maybe 40 characters. Paste it in a message, someone decodes it on their machine, done.
How it works
A panel layout is a tree of cuts. Each node says whether the cut is vertical or horizontal (V/H), its angle in degrees, its split mode (how the cut position is picked), and which child cuts nest inside it. The serializer, CutNode.to_compact, walks that tree recursively and emits something like:
V3_4(V-3_3(H19_3(,),),)
That's a real layout from the pack's samples. The output STRING is PANEL_LAYOUT's lossless text form - encode then decode round-trips without losing anything.
The one input, and a quirk
Just layout, the PANEL_LAYOUT to serialize. It comes from wherever layouts are born: Load Panel Layout, a generator, or String Decode. There's also a quirk worth knowing: this node is marked as an output node, and the code literally prints the encoded string to ComfyUI's console. So even if you don't wire the string anywhere, you'll see it in the terminal output - a handy way to grab a layout code without hunting through your graph.
The trap
The string is opaque by design, so don't treat it as human-editable. Want a different page? Mutate the layout with Mutate Panel Layout and re-encode rather than typing into the string. And remember the encode/decode pair only carries the abstract cut tree - corner shapes, margins, and line styling are applied later by other nodes and are not part of the code.
Install
Same pack, same drill as every node here. ComfyUI Manager → search comfyui-panels → install, or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_panels
cd comfyui_panels
pip install -r requirements.txt
Restart ComfyUI. It lives under Bmad/Panels. Dependencies are shapely, matplotlib, and opencv-python; no model files, no GPU footprint.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| layout | PANEL_LAYOUT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |