🍒JSON_Image_Compositor / JSON图像合成器
JSON_Image_Compositor turns the icon map back into a real image
- 合成预览图
- 统计信息
Somewhere in the KimNodes icon pipeline, the layout stops being pixels and becomes data - a JSON blob describing where every icon went. That's great for reproducibility, but eventually you want the picture back. JSON_Image_Compositor is the render half: it reads a JSON document full of base64-encoded image crops and bbox coordinates, and composites them onto a canvas at the right spots.
It's the bookend to IconDistributeByGrid (which produces that JSON) and to the pack's SeamlessTilingGenerator (whose output the docstring explicitly references). If you're working through the pack's icon-sheet flow, this is how the "data" version of your layout becomes a viewable image again - and because it's JSON-driven, you can hand-edit the layout in any text editor and re-render it without re-running the placement.
How it works
You feed json_data (a JSON string) and 背景颜色 (a hex color, default #FFFFFF). The node parses the JSON and looks for a masks array, where each entry is an object with a base64 mask image and a bbox - four "x,y" strings describing the corners, of which it reads the top-left ([0]) and bottom-right ([2]) as the placement rectangle. It decodes each base64 image, resizes it to the bbox size, pastes it onto the canvas, and collects stats as it goes (how many placed, by type and position).
Canvas sizing is the one knob: by default it auto-computes from the maximum coordinates plus a 50px margin, growing the canvas on the fly if a placement runs past the edge. Turn on 自定义画布尺寸 and you get fixed 画布宽度/画布高度 (256–4096) instead - handy when you want a standard output tile regardless of content.
Outputs: 合成预览图 (the composited IMAGE) and 统计信息 (a JSON string with totals, canvas size, and per-type/position counts).
The inputs that matter
json_data- the layout. Paste theoutput_jsonfrom IconDistributeByGrid, or the SeamlessTilingGenerator output.背景颜色- the canvas fill.#FFFFFFdefault; any 6-digit hex.自定义画布尺寸+ 画布宽度/画布高度 - fixed-canvas mode.
Installation
Standard KimNodes pack install - Manager → search "ComfyUI_KimNodes" → Install → Restart, or git clone https://github.com/wjl0313/ComfyUI_KimNodes into custom_nodes. No extra dependencies (PIL + json + torch).
Common issues
- "JSON中没有找到图像数据" (no image data in JSON) - the JSON isn't in the expected
masksschema, orjson_datais empty. This node is schema-coupled to the pack's generators; other JSON won't parse into placements. - Images paste in the wrong spots or all top-left - the
bboxmust be four"x,y"strings in order. If your source writes bboxes differently (e.g. pixel tuples), the parser won't read them and falls back to a 64×64 default at (0,0). - Auto canvas comes out huge - the auto mode uses max coordinates plus margin; a stray far coordinate blows up the canvas. That's when fixed 自定义画布尺寸 mode earns its keep.
- A red-ish placeholder tile appears - a base64 decode failure returns a gray 64×64 box by design; check the console for "解码base64图像失败" and verify the JSON has valid image data.
It's a purpose-built bridge node - useless on its own, indispensable inside the pack's icon workflow. If you're only installing one node from this pack, this probably isn't it; if you're doing icon sheets, it's the glue.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| json_data | STRING | — | |
| 背景颜色 | STRING | #FFFFFF | — |
| 自定义画布尺寸opt | BOOLEAN | false | — |
| 画布宽度opt | INT | 1024256–4096 | — |
| 画布高度opt | INT | 1024256–4096 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| 合成预览图 | IMAGE | — |
| 统计信息 | STRING | — |