Nodes/NH-Nodes/Layer Layout Composite (NH)
ComfyUI Node

Layer Layout Composite (NH)

Turn a batch of images into a print-ready contact sheet

By jetthuangai·Created 5 months ago·Updated 21 days ago· 6
Layer Layout Composite (NH)
  • images
  • background_image
  • image
  • slot_count
  • used_count
  • layout_info
canvas_width2480
canvas_height3508
background_color#FFFFFF
layout_mode
layout_preset
resize_mode
columns2
rows3
margin_x150
margin_y150
gap_x150
gap_y150
custom_units
custom_layout0.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

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, and gap_x/y.
  • custom - write slot rectangles yourself in the multiline custom_layout box, one x,y,width,height per line, with custom_units of auto, relative, percent, or pixels. 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.

CategoryNH-Nodes/Image

Inputs (17)

NameTypeDefaultDescription
imagesIMAGE
canvas_widthINT24801–20000
canvas_heightINT35081–20000
background_colorSTRING#FFFFFF
layout_modeCOMBO3 options: preset, grid, custom
layout_presetCOMBO8 options: 2x3, 2x3_mixed, 2_top_1_bottom, 1_full, 2_vertical, 2_horizontal, +2
resize_modeCOMBO3 options: cover, contain, stretch
columnsINT21–20
rowsINT31–20
margin_xINT1500–10000
margin_yINT1500–10000
gap_xINT1500–10000
gap_yINT1500–10000
custom_unitsCOMBO4 options: auto, relative, percent, pixels
custom_layoutSTRING0.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_fitCOMBO3 options: stretch, cover, contain
background_imageoptIMAGE

Outputs (4)

NameTypeDescription
imageIMAGE
slot_countINT
used_countINT
layout_infoSTRING