Nodes/comfyui-common-util/Init Layer Info Array
ComfyUI Node

Init Layer Info Array

The blueprint node for layered composites — start every layer scene here

By longgui0318·Created 2 years ago·Updated about a year ago· 1
Init Layer Info Array
    • layerInfoArray
    • layerInfoArrayJson
    width0
    height0
    prompt
    reference_bg
    number_of_results0
    correct_colortrue
    render_strength
    color_strength
    outline_strength

    "Init Layer Info Array" is the starting point of this pack's layer system - a small family of nodes for describing a multi-layer composite as structured data, then rendering it back into images and masks. Its job is to create the blueprint: a JSON object that records the canvas size, a generation prompt, a reference background, and a set of style/strength toggles, ready to be filled in with individual layers.

    If the shape of this is bugging you - "Product", "Prop", "Human-Hand", "Human-Male", "Human-Female" layer types, a "number of results" field, render/color/outline strength dropdowns - it's because this pack is aimed squarely at e-commerce-style product photography: hands holding products, models wearing them, props staged around them. The whole layer subsystem is built to describe that kind of scene. What this pack alone does not do is render AI-generated layers for you. It's the data model. You build the description with this node and its sibling "Added Layer Info To Array", then "Layer Info Array Fuse" turns it back into real composited images and masks. The rendering you get locally is straight compositing; the fancier strengths are metadata that only mean something to a downstream consumer.

    How it works

    On execution it packages everything into a dict - width, height, prompt, reference_bg, number_of_results, correct_color, the three strength dropdowns, and an empty layers list - and hands it out twice: once as a typed LAYER_INFO_ARRAY for wiring into other nodes, and once as a JSON string (layerInfoArrayJson) for anything that wants the raw text.

    Inputs that matter

    • width, height (INT, default 0) - canvas dimensions for the composite. Set these to your actual output size; 0 is a placeholder.
    • prompt (STRING, multiline) - a generation prompt that rides along with the scene data.
    • reference_bg - a dropdown of files in ComfyUI's input folder. This is your background reference image; it has to be a real file in ComfyUI/input.
    • number_of_results (INT) - how many results a downstream renderer should produce. Metadata only, here.
    • correct_color (BOOLEAN, default on) - color-correction toggle, again metadata in this pack.
    • render_strength, color_strength, outline_strength - dropdowns from "Default"/"Weak"/"Strong" up to "Extra Strong". Stored in the JSON, passed through.

    Outputs

    • layerInfoArray (LAYER_INFO_ARRAY) - wire this into "Added Layer Info To Array".
    • layerInfoArrayJson (STRING) - the same data as JSON text.

    The honest caveats

    Two things to know so you're not confused later. First, the strength dropdowns don't change anything inside this pack - the fuse node mostly passes them through, and the "strength" outputs it returns are hardcoded to 0 in the current source. They only matter if something downstream actually reads them. Second, if reference_bg is left empty, the fuse step falls back to a tiny white placeholder rather than skipping the background - so set it unless you want a 100×100 white square in your output.

    Installing it

    Part of longgui0318/comfyui-common-util:

    cd ComfyUI/custom_nodes
    git clone https://github.com/longgui0318/comfyui-common-util
    cd comfyui-common-util && pip install -r requirements.txt
    

    Restart after, or use ComfyUI Manager and search "comfyui-common-util". requirements.txt lists only opencv-python, but the pack imports scipy, scikit-image, and PyWavelets at load - if it won't load, pip install scipy scikit-image PyWavelets then restart. And note the layer system's fanciest member, "Layer Images IPAdapter Advanced", additionally needs cubiq's ComfyUI_IPAdapter_plus installed.

    Categoryutils

    Inputs (9)

    NameTypeDefaultDescription
    widthINT0
    heightINT0
    promptSTRING
    reference_bgCOMBO1 options: example.png
    number_of_resultsINT0
    correct_colorBOOLEANtrue
    render_strengthCOMBO5 options: Default, Extra Weak, Weak, Strong, Extra Stong
    color_strengthCOMBO5 options: Default, None, Weak, Strong, Extra Stong
    outline_strengthCOMBO6 options: Default, None, Extra Weak, Weak, Strong, Extra Stong

    Outputs (2)

    NameTypeDescription
    layerInfoArrayLAYER_INFO_ARRAY
    layerInfoArrayJsonSTRING