Eric Qwen Layer Reorder
Fix the stacking order of your layers before you save or composite
- layers
- alpha_masks
- reordered_layers
- reordered_masks
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_amountpositions (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,0incustom_order. This is the one you'll actually use when you know exactly where each layer belongs. - shuffle: random order, seeded by
seedso 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.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| layers | IMAGE | — | |
| mode | COMBO | reverse | Reordering mode |
| alpha_masksopt | MASK | — | |
| custom_orderopt | STRING | 0,1,2,3 | Custom order as comma-separated indices |
| rotate_amountopt | INT | 11–20 | How many positions to rotate |
| seedopt | INT | 00–4294967295 | Seed for shuffle mode |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| reordered_layers | IMAGE | — |
| reordered_masks | MASK | — |