Nodes/Qwen Layers Diffuser Pipeline/Eric Qwen Layer Reorder
ComfyUI Node

Eric Qwen Layer Reorder

Fix the stacking order of your layers before you save or composite

By EricRollei·Created 8 months ago·Updated 8 months ago· 6
Eric Qwen Layer Reorder
  • layers
  • alpha_masks
  • reordered_layers
  • reordered_masks
modereverse
custom_order0,1,2,3
rotate_amount1
seed0

Layer order matters. The Decompose node hands you a batch where the background is usually first and foreground elements come after, but "usually" isn't "always," and once you start selecting and merging layers the order you need rarely matches the order you got. EricQwenLayerReorder exists so you can reshuffle the stack before it hits the Composite or Save node - without touching the pixel data.

Modes

  • reverse: flips the whole stack, last layer first.
  • rotate_up / rotate_down: shift the batch by rotate_amount positions (1–20), rolling around the ends. Rotating up one position moves the first layer to the back - good for testing "what if this element were behind everything."
  • custom: pass a comma-separated index list like 3,2,1,0 in custom_order. This is the one you'll actually use when you know exactly where each layer belongs.
  • shuffle: random order, seeded by seed so you can reproduce a given shuffle for an "explore variations" batch run.

The optional alpha_masks input gets reordered in parallel, and the outputs are reordered_layers and reordered_masks - one-to-one with the input, always. That parallel handling is the quietly important part: it's trivial to forget that a mask batch has to be permuted with the exact same permutation as the image batch, and this node guarantees it does.

Where it slots in

Two common spots. Before Composite, so the blend happens in the z-order you want (background on the bottom). Before Layer Save, so the PSD's layer panel reads the way you intend - Photoshop opens the file with layers in whatever order they were written. If you've ever gotten a PSD back where the subject is sandwiched under the background, this node is the fix.

Small tip: custom_order indices are zero-based and refer to positions in the current batch, not names. If you've reordered before, index 0 is whatever is first now. For anything more than a handful of layers, read the layer_info JSON from Decompose first so you're not guessing.

Standard install for the pack: ComfyUI Manager (search "Eric Qwen") or git clone https://github.com/EricRollei/Qwen_Layers_Diffuser_Pipeline_Comfyui into custom_nodes, then restart. No model needed - it's a batch permute.

CategoryEric Qwen Layer

Inputs (6)

NameTypeDefaultDescription
layersIMAGE
modeCOMBOreverseReordering mode
alpha_masksoptMASK
custom_orderoptSTRING0,1,2,3Custom order as comma-separated indices
rotate_amountoptINT11–20How many positions to rotate
seedoptINT00–4294967295Seed for shuffle mode

Outputs (2)

NameTypeDescription
reordered_layersIMAGE
reordered_masksMASK