A professional command-line tool for Game Developers (especially tailored for MonoGame/XNA ecosystem) to pack scattered PNG frames into a single, highly optimized Sprite Sheet.
It utilizes the advanced MaxRects Bin-Packing Algorithm to ensure zero wasted space and outputs a TexturePacker-compatible JSON format.
- Advanced Bin-Packing: Uses the industry-standard MaxRects algorithm (Best Short Side Fit) for maximum space optimization compared to basic shelf packing.
- Auto-Grouping (
--auto-group): Automatically detects sprite prefixes (e.g.,hero_run_1.pngandzombie_walk_1.png) and groups them into separate sprite sheets (spritesheet_hero_run.png,spritesheet_zombie_walk.png) on the fly. - Smart Filtering (
--filter): Safely filter specific files using glob patterns (e.g.,--filter "zombie_*.png") with built-in case-sensitivity and OS-agnostic protection. - MonoGame Ready: Directly exports TexturePacker JSON (Array format), easily readable by MonoGame.Extended or custom content pipelines.
You can either run this tool as a standalone executable (no installation required) or as a Python script.
- Download the
sprite-packer-cli.exefrom the Releases tab (or find it in yourdist/folder if you built it yourself). - Simply double-click the
.exefile. - An interactive wizard will open in the terminal and ask you for the necessary paths and options!
Ensure you have Python 3.x installed. Then install the required dependencies:
pip install -r requirements.txtThe easiest way to use the tool is through its built-in interactive wizard. You don't need to type any complex commands!
- Double-click the
sprite-packer-cli.exefile. - A terminal window will open and guide you step-by-step:
- Input Directory: Where your scattered
.pngfiles are located. (Press Enter to use the default./inputfolder). - Output Paths: Where to save the packed
.pngand.jsonfiles. - Max Width/Height: Constrain the texture size (useful for mobile game limits).
- Auto-Group: Type
yif you want to automatically separate different animations into their own files based on their names (e.g.,hero_run,hero_jump).
- Input Directory: Where your scattered
- Hit Enter and watch it instantly pack your sprites!
If you prefer to use the tool in scripts or CI/CD pipelines, you can bypass the interactive wizard by providing arguments directly:
python packer.py <input_dir> <output_image> <output_json> [options](If you are using the executable, replace python packer.py with sprite-packer-cli.exe)
Packs all .png and .PNG files in the input directory and creates spritesheet.png and spritesheet.json.
python packer.py ./examples/input ./examples/output/spritesheet.png ./examples/output/spritesheet.jsonGroups files by their prefixes (ignores trailing numbers and underscores) and outputs multiple sprite sheets.
python packer.py ./examples/input ./examples/output/spritesheet.png ./examples/output/spritesheet.json --auto-group(E.g., Generates spritesheet_hero_run.png and spritesheet_zombie_walk.png)
Pack only specific sprites using a glob pattern.
⚠️ Note: Always wrap your filter in quotes to prevent unwanted terminal shell expansion!
python packer.py ./examples/input ./examples/output/spritesheet.png ./examples/output/spritesheet.json --filter "zombie_*.png"By default, max width is 1024 and max height is 8192. You can override these limits:
python packer.py ./examples/input ./examples/output/spritesheet.png ./examples/output/spritesheet.json --max-width 2048 --max-height 2048- Language: Python 3
- Image Processing:
Pillow(PIL) - Algorithm: 2D MaxRects Bin-Packing (Splits free rectangles dynamically as images are placed, keeping the canvas as small as possible).