Nodes/comfyui-moonpack/Reference Grid
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.

By moonwhaler·Created about a year ago·Updated 4 days ago· 15
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)

NameTypeDefaultDescription
reference_imagesIMAGEReference 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.
columnsINT00–8192Number of grid columns. 0 = auto (ceil(sqrt(n)), a roughly square grid).
fit_modeCOMBOcoverHow 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_sourceCOMBOlargestWhich references set the cell size (per axis, independently): the largest reference (upscales smaller ones), the smallest (downscales larger ones), or the average dimensions.
cell_widthINT00–8192Fixed cell width override. 0 = use cell_size_source.
cell_heightINT00–8192Fixed cell height override. 0 = use cell_size_source.
fill_directionCOMBOrow_majorOrder references fill the grid. 'row_major': left to right, then top to bottom. 'column_major': top to bottom, then left to right.
last_row_alignCOMBOleftAlignment 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.
fillCOMBOblackBackground color for empty cells and any 'contain' padding. 'edge_average' uses the mean color of all references.
interpolationCOMBObicubicResampling filter used whenever a reference image is resized.
max_ref_sideINT00–8192Caps 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_maskBOOLEANfalseFlip the output mask (empty/padding area becomes 1.0 instead of the reference area).

Outputs (2)

NameTypeDescription
imageIMAGE
maskMASK