Interactive Python tool to split a sprite sheet into individual PNG frames.
- Interactive terminal prompts
fixed_gridmode for evenly spaced sprite sheetsauto_detectmode for transparent-background sprite sheets- Output organized by row:
row_1,row_2, etc.
- Python 3.9+ (recommended)
- Pillow (listed in
requirement.txt)
From the project root directory:
python -m venv .venv
source .venv/bin/activate
pip install -r requirement.txtRun:
python main.pyThe script will ask for:
- Sprite sheet image path
- Output directory
- Extraction mode (
fixed_gridorauto_detect) - Mode-specific settings
Use this when all frames are aligned in equal rows/columns:
Path to sprite sheet image [pet1.png]: assets/character.png
Output directory [extracted]: character_frames
Extraction mode: 'fixed_grid' or 'auto_detect' [fixed_grid]:
--- Fixed Grid Settings ---
Number of rows [5]: 4
Number of columns (frames per row) [5]: 6
Do you want to specify custom cell width/height? (otherwise auto-calculated) [y/N]: n
Use this when the sheet size is not perfectly divisible by rows/columns:
Path to sprite sheet image [pet1.png]: assets/monster.png
Output directory [extracted]: monster_frames
Extraction mode: 'fixed_grid' or 'auto_detect' [fixed_grid]:
--- Fixed Grid Settings ---
Number of rows [5]: 3
Number of columns (frames per row) [5]: 8
Do you want to specify custom cell width/height? (otherwise auto-calculated) [y/N]: y
Cell width (pixels): 64
Cell height (pixels): 64
Use this when sprites are separated by transparent gaps:
Path to sprite sheet image [pet1.png]: assets/effects.png
Output directory [extracted]: effects_frames
Extraction mode: 'fixed_grid' or 'auto_detect' [fixed_grid]: auto_detect
--- Auto-Detect Settings ---
Alpha threshold (pixels with alpha <= this are empty) [10]: 10
Minimum gap (empty pixels) between sprites/rows [2]: 2
If output directory already exists:
Directory 'character_frames' already exists. Overwrite? [y/N]: y
Existing files will be overwritten if names conflict.
If you answer n, the tool exits.
The extractor saves PNG files like:
character_frames/
row_1/
frame_1.png
frame_2.png
...
row_2/
frame_1.png
frame_2.png
...
fixed_grid: frames are cropped using row/column coordinates.auto_detect: only pixels with alpha above threshold are treated as content.- For best
auto_detectresults, keep clear transparent spacing between sprites.