ComfyUI Node
Reference Grid
Arranges a batch of reference images into a contact-sheet grid, with full control over column count, per-cell fit mode, cell sizing, fill order and alignment of an incomplete last row/column. Accepts either a MoonPack Image List (keeps each reference's native resolution) or a plain stacked IMAGE batch.
Reference Grid
- reference_images
- image
- mask
◄columns0►
◄fit_modecover►
◄cell_size_sourcelargest►
◄cell_width0►
◄cell_height0►
◄fill_directionrow_major►
◄last_row_alignleft►
◄fillblack►
◄interpolationbicubic►
◄max_ref_side0►
◄invert_maskfalse►
CategoryMoonPack/image
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| reference_images | IMAGE | Reference images to arrange into a grid. Connect a MoonPack Image List to keep each image's native resolution (recommended for mixed-resolution references), or a plain stacked IMAGE batch. | |
| columns | INT | 00–8192 | Number of grid columns. 0 = auto (ceil(sqrt(n)), a roughly square grid). |
| fit_mode | COMBO | cover | How each reference fills its cell. 'cover': scale to fill, center-crop the overflow. 'contain': scale to fit inside, pad the leftover with fill color. 'stretch': force an exact fit, distorting aspect ratio. |
| cell_size_source | COMBO | largest | Which references set the cell size (per axis, independently): the largest reference (upscales smaller ones), the smallest (downscales larger ones), or the average dimensions. |
| cell_width | INT | 00–8192 | Fixed cell width override. 0 = use cell_size_source. |
| cell_height | INT | 00–8192 | Fixed cell height override. 0 = use cell_size_source. |
| fill_direction | COMBO | row_major | Order references fill the grid. 'row_major': left to right, then top to bottom. 'column_major': top to bottom, then left to right. |
| last_row_align | COMBO | left | Alignment of the incomplete trailing row (row_major) or column (column_major, where left/right act as top/bottom) when the reference count doesn't evenly divide the grid. |
| fill | COMBO | black | Background color for empty cells and any 'contain' padding. 'edge_average' uses the mean color of all references. |
| interpolation | COMBO | bicubic | Resampling filter used whenever a reference image is resized. |
| max_ref_side | INT | 00–8192 | Caps each reference's longest side to this many pixels before any other processing (downscale only, never upscales). Keeps one oversized reference from blowing up the grid size. 0 = no cap. |
| invert_mask | BOOLEAN | false | Flip the output mask (empty/padding area becomes 1.0 instead of the reference area). |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |