Skip to main content
Built by Best ROI MediaMITWave 2 · LiveBestRoiMedia/bestroi-game-tools

sheets

Sprite-sheet slicer, border-flood chroma keyer, and labelled review contact-sheet builder.

Fast command-line sprite-sheet utility suite for slicing multi-item sheets into transparent PNGs, keying out border-connected flat backgrounds with soft despilled edges, and assembling labelled contact sheets.

View on GitHub ↗
Quick clonegit clone https://github.com/BestRoiMedia/bestroi-game-tools.git
GitHub repositoryBestRoiMedia/bestroi-game-tools
Module path_tools/sheets/
LicenseMIT
Release waveWave 2
LanguagesPython · JSON

Why we built it

AI image generators frequently pack multiple icons or poses onto a single sheet or render characters on solid magenta/green backgrounds. Naive color keying deletes matching hues inside the character, and manual cropping wastes time. We built sheets to automate border-flood keying, reading-order slicing, and visual review grids.

Architecture & how it works

slice_sheet.py flood-fills from the sheet border over near-background colors so interior highlights stay intact, finds the N largest connected components via scipy.ndimage, and exports padded square PNGs in top-to-bottom, left-to-right reading order. key_colour.py computes channel key-ness in NumPy and removes only border-connected key pixels (magenta, green, blue, or custom hex) with soft edge feathering and despill. contact_sheet.py lays out labelled image globs or JSON specs onto solid or checkerboard backgrounds.

Key capabilities

  • Border-flood background removal in both slice_sheet.py and key_colour.py to preserve interior colors
  • Reading-order connected-component sprite slicing with configurable output size and padding
  • NumPy-accelerated chroma keying for magenta, green, blue, or arbitrary #RRGGBB hex backgrounds
  • Labelled contact-sheet generator supporting CLI row globs or JSON specs and checkerboard backdrops
  • Structured JSON stdout reporting for every cut, keyed, or composited output

Usage example

Slice a sprite sheet, key a magenta background, and build a contact sheetPython
python3 sheets/slice_sheet.py ./sheet.png ./out/items icon_a,icon_b,icon_c --size 256 --tol 36
python3 sheets/key_colour.py ./raw/*.png --key magenta --out-dir ./cut
python3 sheets/contact_sheet.py --out ./review.png --title "Items" --row "Cut=./cut/*.png:200" --checker
slice_sheet.py automatically re-execs with SHEETS_PY if SciPy is installed in a separate virtual environment.