[Script] Export sprite's layers as individual images

Introduction and description

Hi!
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.

Usage

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 responsable 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.

Download

You can download the latest version from here.

Instalation

To install a script, copy the .lua file into aseprite’s script path. Then, open Aseprite or restart it if it was already open.
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!

Changelog

  • 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 usefull and thank you very much for using my script!
Any comment, feedback or suggestion is appreciated!

3 Likes

Hi @Gaspi, thanks for sharing and welcome to Aseprite community! :smiley:

I’ve added this script to the list of scripts I’m collecting here , I hope you don’t mind :slight_smile:

Is there any possibility that you add support for Windows to the script? (maybe asking about the OS in the code to choose one way of using paths or another? I’m a bit noob so I’m not sure if that can be done easily in lua).

1 Like

Hi, @JJHaggar!

Thank you very much for the wellcome! I updated the script and it now works both on Linux and Windows. The way I did os recognition is not the best but it should be fine.

Have a nice day!

1 Like

That’s great, thank you very much! :smiley: