Nodes/ComfyUI-nhknodes/πŸ”² Load 2x2 Grid Series (nhk)
ComfyUI Node

πŸ”² Load 2x2 Grid Series (nhk)

Slices every image in a folder into its 2x2 grid cells β€” reading order, on autopilot

By EnashkaΒ·Created 12 months agoΒ·Updated 28 days agoΒ· 23
πŸ”² Load 2x2 Grid Series (nhk)
    • image
    • filename
    • current_index
    • total_images
    • grid_position
    • position_name
    β—„modeβ–Ύβ–Ί
    β—„pathβ–Ί
    β—„pattern*β–Ί
    β—„index0β–Ί
    β—„seed0β–Ί
    β—„labelGrid2x2_001β–Ί
    β—„resetfalseβ–Ί
    β—„separator_width0β–Ί

    If your source images aren't images at all but 2x2 contact grids - four generations composited into one PNG - then the stock LoadImage is useless to you and every manual crop is a tax on your patience. Load2x2GridSeries is the node that treats each file in a folder as a 2x2 grid and hands you one cell at a time, in reading order, on autopilot: upper-left, upper-right, bottom-left, bottom-right, then on to the next file. It's a sibling of LoadImageSeries, same counter mechanics, one extra trick: it splits.

    This is the pattern the pack is built around, so if you've used LoadImageSeries you already know the drill - mode, path, pattern, label, reset. The new bit is separator_width.

    How it works

    Each source image is cut into four quadrants (width // 2 by height // 2). The node keeps a per-label in-memory counter just like LoadImageSeries, but now the sequence is measured in cells, not files: total_grid_cells = number_of_files Γ— 4. So index 0–3 are file 1's four quadrants, index 4–7 are file 2's, and so on, wrapping around at the very end.

    • single_image mode loads by index and auto-advances one cell per run; reset sends it back to cell 0.
    • random mode picks a random cell (0 to cellsβˆ’1) from a seeded RNG - same seed, same cell.
    • separator_width (default 0) is for grids that have a visible divider line between cells. If your composites were built with a 2px gutter down the middle, a naive width//2 crop will slice through the line and give you sloppy edges. Set separator_width to the line thickness and the node crops around it, excluding those pixels from each quadrant.

    Outputs tell you exactly where you are in the whole sequence: image (the cropped cell), filename (the source file it came from), current_index (cell index across all files), total_images (total cells = files Γ— 4), plus grid_position (0–3) and position_name ("upper-left", "upper-right", "bottom-left", "bottom-right").

    Installing

    Standard pack install, no model downloads, no extra dependencies:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Enashka/ComfyUI-nhknodes
    

    or ComfyUI Manager β†’ search "NHK Nodes" β†’ install β†’ restart. It shows up under nhk/image.

    Where people get burned

    • Cropped cells have white/black slivers on the edges. Your grids have a separator gutter and separator_width is 0. Measure the gutter and set it - the whole point of that input is fixing exactly this.
    • "It's skipping whole files / repeating cells." The counter tracks cells, not files. If you're expecting per-file steps, remember a "step" here is one quadrant. position_name on the output tells you which corner of which file you're on - trust that over guessing.
    • Odd dimensions. It's integer division, so a grid with an odd pixel width loses a column of pixels to the split. Not much you can do about it, but it's worth knowing the last pixel column/row effectively disappears.
    • Same counter trap as its sibling. Change folders without changing the label and it'll pick up where the old sequence left off. Fresh label or reset when you repoint it.

    This node exists for one specific workflow - "my dataset/outputs are 2x2 grids and I want each cell as its own frame" - and for that job it's the best of the bunch. If you've got 3x3 grids instead, grab its sibling Load3x3GridSeries; the logic is identical, just 9 cells per file.

    Categorynhk/image

    Inputs (8)

    NameTypeDefaultDescription
    modeCOMBOsingle_image: load by index (use with control_after_generate=increment for sequences), random: load random grid cell by seed
    pathSTRINGDirectory path containing grid images to load
    patternSTRING*Glob pattern to filter files (e.g., '*.png', 'img_*.jpg', '**/*.png' for recursive)
    indexINT0Starting index for single_image mode (auto-increments with control_after_generate)
    seedINT0Seed for random mode (same seed = same random grid cell)
    labelSTRINGGrid2x2_001Unique identifier for tracking this sequence independently from others
    resetBOOLEANfalseReset counter back to index 0
    separator_widthINT00–100Width of separator lines between grid cells (in pixels). Excludes this many pixels from center cross.

    Outputs (6)

    NameTypeDescription
    imageIMAGEβ€”
    filenameSTRINGβ€”
    current_indexINTβ€”
    total_imagesINTβ€”
    grid_positionINTβ€”
    position_nameSTRINGβ€”