SpriteStitcher is a lightweight and simple command-line tool that stitches multiple PNG images into a single sprite atlas, or unpacks a sprite atlas back into its individual images.
It's written in C# (.NET 8), portable, and built with game developers and pixel artists in mind.
- Stitch PNG images into an optimized atlas using skyline-packing.
- Unstitch existing atlases back into individual images.
- JSON metadata for use in engines or your own tools.
SpriteStitcher.exe <folder> --stitch <name> [--padding <n - default 2>]Stitch takes every .png file within the specified directory (but not subdirectories!)
and combines them all into a single .png image, with the specified padding of n pixels between each image.
SpriteStitcher.exe C:\MySprites --stitch "my_atlas.png" --padding 4This command will:
- Create a subdirectory called
stitchedwithinC:\MySpritesto store the atlas - Stitch all
.pngfiles together into an atlas calledmy_atlas.png, with a padding of 4 pixels between each sprite. - Generate the relevant metadata within
my_atlas.json.
SpriteStitcher.exe <folder> --unstitch <atlas.png>Unstitch takes in a PNG of an atlas and, using its metadata, separates it into its original images.
SpriteStitcher.exe D:\MySprites\stitched --unstitch my_atlas.pngThis command will:
- Create the subdirectory
unstitched. - Parse
my_atlas.jsonto process each image within the atlas - Extract all images to
unstitched - Ask to delete the atlas and metadata
Each atlas is accompanied by a .json file in the following format:
{
"image": "atlas.png",
"sprites": {
"sprite1.png": { "x": 0, "y": 0, "width": 32, "height": 32 },
...
}
}You do not need to build SpriteStitcher directly from the source. Just go to Releases and download the latest version!
I made SpriteStitcher as part of my effort to familiarize myself with C#. That being said, it also fills a large gap within my workflow and I'd love to see it flourish. So, Pull Requests, forks, and anything in between is welcome! If you'd like SpriteStitcher to have a certain feature please do not hesitate to open up an issue or a PR!
Credits: White Tower Games / Christos Maragkos: Programming and Testing
- (Currently) assumes non-rotated, top-left anchored sprites.
- Atlas max width is set to 4096.
- Only
.pngimages are supported.