I’m working on a game where characters are drawn in layers, so you can choose their clothes and complements. As I was making these sprites I started to miss a function to export all layers on a sprite as individual png images with their own name and on a specific folder. I couldn’t find this feature, so I investigated and found that there is an api for Aseprite, so I made my own script that does just that before making sure there was no way to do it other way.
NOTE.- This script should only work on Linux/GNU and Windows machines. Not tested on any other operative system, although it should work on Mac OS as well.
NOTE 2.- No hard testing went into this script. It should work fine, but use at your own risk. I’m not responsible of any bad use of the script nor unexpected behavior of it.
To execute the script just run it (File → Scripts → Export Layers) and all layers will be exported to their respective png file. If your sprite has multiple frames, all layers for all frames will be exported with their frame index at the end of the file name.
The images are saved on a new folder where the original file is located. I saw on the github repository issues that there is a function to ask the user for a directory on the go, so this is a temporary location until that function is added.
You can download the latest version from here.
To install a script, copy the .lua file into Aseprite’s script path (you can find it in File → Scripts → Open Scripts Folder) . Then, if Aseprite was open, rescan the scripts folder (F5 by default or File → Scripts → Rescan Scripts Folder) or simply restart Aseprite.
For a detailed guide on scripts, check out @JJHaggar’s collection, as it includes a detailed guide on how to install and use scripts as well as a bunch of them!
- v1.3 - Fixed layers in groups not exporting after API v1.2.14 changes.
- v1.2 - Improved file name with sprites with multiple frames.
- v1.1 - Added Windows support and an error message if no sprite is currently active.
- v1.0 - Initial release.
I hope you find this script useful and thank you very much for using my script!
Any comment, feedback or suggestion is appreciated!