Nodes/ComfyUI-QwenImageLayeredToLength/QwenImageLayered - Layer to Length Mapper
ComfyUI Node

QwenImageLayered - Layer to Length Mapper

3 layers is 13, and this node is why you'll stop guessing

By benjiyaya·Created 8 months ago·Updated 8 months ago· 9
QwenImageLayered - Layer to Length Mapper
    • length
    num_layers1

    If you've ever run a Qwen-Image-Layered workflow and stared at a "length" box that says 5, 9, 13, 17, 21 and wondered what the hell those numbers are, this node is the answer wearing a name tag. The Layer to Length Mapper converts "I want N layers" - a number you actually understand - into the opaque length value the model needs. It's a single integer in, a single integer out, and honestly, it's the only part of a layered workflow that makes any intuitive sense.

    Why this exists at all

    Qwen-Image-Layered (Alibaba, December 2025) decomposes an image into independent RGBA layers so you can edit one element without redrawing the rest - the release the community reacted to with "in 6 months, Photoshop will be useless." When ComfyUI added official support (this traces back to a comfyanonymous thread), the implementation borrowed the EmptyHunyuanLatentVideo node as a latent generator, because a layered output is just a video-shaped latent where each frame is one layer. So the thing the workflow calls "length" isn't a count of layers at all - it's a sequence length with a weird offset. Mapping length → layers by hand is exactly how you misclick a 3-layer job into a 2-layer one.

    The mechanism, in full

    The whole pack is one function:

    length = 5 + (num_layers - 1) * 4
    

    Which means:

    | Layers | length | |--------|--------| | 1 | 5 | | 2 | 9 | | 3 | 13 | | 4 | 17 | | 8 | 33 |

    The base of 5 and the +4 per layer is just what the implementation expects; don't fight it, feed it. The current build caps you at 8 layers (length 33). An earlier version capped at 5 and - worth knowing - silently returned 5 even if you asked for more, so an old install will quietly give you fewer layers than you requested.

    The input and output that matter

    There's one input and one output, so this is a short list:

    • num_layers (INT, default 1, min 1, max 8) - how many layers you want. That's it. That's the whole control surface.
    • length (INT) - the number to feed into the latent's length input, i.e. the length widget on EmptyHunyuanLatentVideo in the official layered workflow. A LatentCutToBatch node after sampling slices each frame into its own image, giving you N layer PNGs.

    Install

    Zero dependencies, zero models, zero requirements.txt - this pack is pure Python with no package requirements, so install is the boring, easy kind:

    cd ComfyUI/custom_nodes
    git clone https://github.com/benjiyaya/ComfyUI-QwenImageLayeredToLength
    

    Then restart ComfyUI. You can also grab it through ComfyUI Manager by searching for ComfyUI-QwenImageLayeredToLength. The actual heavy lifting - the ~40 GB qwen_image_layered_bf16.safetensors diffusion model, the text encoder, and the layered VAE - comes from Comfy-Org's Qwen-Image-Layered_ComfyUI HuggingFace repo (or a GGUF quant from QuantStack/Qwen-Image-Layered-GGUF if your VRAM is small). None of that is this pack's job.

    Where people get burned

    Most problems here are upstream of the node. The model is a 20B MMDiT that runs slow, needs serious VRAM at full precision, and community reports on heavily quantized versions (Q5 on 8 GB) range from "meh" to "not satisfying." If your output looks bad, that's the model, not this five-line mapper.

    One real trap from the README's own changelog: higher layer counts don't mean more detail, they mean more separable layers, and the hard cap is 8. If the workflow's length box ever shows a number that isn't 5 + 4·(n−1), the mapper isn't wired into it - check that the length output is actually connected to the latent's length input, not sitting there decorative.

    Categoryutils

    Inputs (1)

    NameTypeDefaultDescription
    num_layersINT11–8

    Outputs (1)

    NameTypeDescription
    lengthINT