Layer Layout Composite (NH)
Turn a batch of images into a print-ready contact sheet
- images
- background_image
- image
- slot_count
- used_count
- layout_info
When you've generated a batch of variations and you need them on one page - a lookbook sheet, a comparison grid for a client, a print-ready layout - you can reach for ComfyUI's grid composite nodes. But most of them just tile cells edge to edge. Layer Layout Composite (NH) (class NH_LayerLayoutComposite) is the one that thinks in terms of a canvas: you give it an image batch and it lays them into preset slots on a background of your size, with margins, gaps, and resize behavior, like a little print-layout engine.
How it works
It creates an RGB canvas (default 2480×3508 - that's A4 at 300 DPI, a tell that this was built with print and product sheets in mind), fills it with a hex background_color or an optional background_image, then pastes each image from your batch into a computed slot. Slots come from one of three layout_modes:
- preset - a handful of hand-arranged layouts (
2x3,2x3_mixed,2_top_1_bottom,1_full,2_vertical,2_horizontal,3_vertical,4_grid). - grid - plain rows × columns with
columns,rows,margin_x/y, andgap_x/y. - custom - write slot rectangles yourself in the multiline
custom_layoutbox, onex,y,width,heightper line, withcustom_unitsofauto,relative,percent, orpixels. The default custom layout is a six-slot sheet.
resize_mode decides how each image fills its slot: cover crops to fill, contain fits inside (letterboxed), stretch squashes. The outputs - slot_count, used_count, and a JSON layout_info string - tell you how many slots existed versus how many images actually got placed, which is handy when your batch is smaller than the layout.
Where you'd actually use it
This is a batch-to-presentation node. Run your 12 variations, feed the batch in, pick 2x3_mixed or a custom sheet, and you get a single composited page out. It plays well with the rest of the NH pack: Load Images Folder (NH) or Load images matching upstream to pull a folder of shots, then NH Large Image Preview downstream so the sheet doesn't choke the browser. It's an IMAGE output (not an output node), so you can pipe the composite straight into a save node - and since the workflow bakes into your PNG, the sheet is self-documenting per the usual ComfyUI convention.
Installing
ComfyUI Manager → search NH-Nodes → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Restart and refresh the browser tab. This node uses only Pillow/numpy from the pack requirements.
Gotchas
The defaults are print-sized, so if you just want a quick on-screen grid, drop the canvas to something like 1024×1024 first - a 2480px canvas is slower and pointless for a screen grab. And note the difference from Layer Stack Composite (NH): that one pastes onto a specific background with explicit coordinates; this one does the slot-based layout math for you. If your image batch is bigger than the layout, extra images silently don't get placed - check used_count before you send it to a printer.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| canvas_width | INT | 24801–20000 | — |
| canvas_height | INT | 35081–20000 | — |
| background_color | STRING | #FFFFFF | — |
| layout_mode | COMBO | 3 options: preset, grid, custom | |
| layout_preset | COMBO | 8 options: 2x3, 2x3_mixed, 2_top_1_bottom, 1_full, 2_vertical, 2_horizontal, +2 | |
| resize_mode | COMBO | 3 options: cover, contain, stretch | |
| columns | INT | 21–20 | — |
| rows | INT | 31–20 | — |
| margin_x | INT | 1500–10000 | — |
| margin_y | INT | 1500–10000 | — |
| gap_x | INT | 1500–10000 | — |
| gap_y | INT | 1500–10000 | — |
| custom_units | COMBO | 4 options: auto, relative, percent, pixels | |
| custom_layout | STRING | 0.06,0.04,0.39,0.20 0.55,0.04,0.39,0.20 0.06,0.28,0.39,0.20 0.55,0.28,0.39,0.20 0.06,0.58,0.39,0.36 0.55,0.58,0.39,0.36 | — |
| background_fit | COMBO | 3 options: stretch, cover, contain | |
| background_imageopt | IMAGE | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| slot_count | INT | — |
| used_count | INT | — |
| layout_info | STRING | — |