Nodes/ComfyUI_KimNodes/🍒JSON_Image_Compositor / JSON图像合成器
ComfyUI Node

🍒JSON_Image_Compositor / JSON图像合成器

JSON_Image_Compositor turns the icon map back into a real image

By wjl0313·Created 2 years ago·Updated 12 months ago· 54
🍒JSON_Image_Compositor / JSON图像合成器
    • 合成预览图
    • 统计信息
    json_data
    背景颜色#FFFFFF
    自定义画布尺寸false
    画布宽度1024
    画布高度1024

    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 the output_json from IconDistributeByGrid, or the SeamlessTilingGenerator output.
    • 背景颜色 - the canvas fill. #FFFFFF default; 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 masks schema, or json_data is 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 bbox must 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.

    Category🍒 Kim-Nodes/🧩Icon Processing | 图标处理

    Inputs (5)

    NameTypeDefaultDescription
    json_dataSTRING
    背景颜色STRING#FFFFFF
    自定义画布尺寸optBOOLEANfalse
    画布宽度optINT1024256–4096
    画布高度optINT1024256–4096

    Outputs (2)

    NameTypeDescription
    合成预览图IMAGE
    统计信息STRING