OK, I wrote a bash script to first export to GIF then re-export them to png spritesheets (using aseprite each time).
It would be even better as an Aseprite script (so we have a command, can bind a shortcut to it and possibly even a popup window so user can set custom parameters) but I need to have a look at the Lua API.
Note that it creates a temporary “temp” sub-folder to do the job.
#!/usr/bin/env bash
# Posted on https://community.aseprite.org/t/how-can-i-export-multiple-spritesheets-at-once/6165
# Consider porting this to Aseprite Lua API for an integrated menu command
usage() {
echo "Usage: export_spritesheets_from_aseprite_tags.sh aseprite_filepath
Export all tagged animations in .aseprite file to spritesheets, one spritesheet per tag, to some Export sub-folder,
using the format '[file_basename]_[tag]_spritesheet.png'
Requirements:
- asprite installed and binary in PATH
ARGUMENTS
aseprite_filepath Path to aseprite file containing the tagged animations, including extension
"
}
if ! [[ $# -eq 1 ]]; then
echo "Wrong number of positional arguments: found $#, expected 1."
echo "Passed positional arguments: $@"
usage
exit 1
fi
aseprite_filepath="$1"
shift 1
# Ex: "character"
file_basename=${aseprite_filepath%.*}
# Setup temp dir
rm -rf temp
mkdir -p temp
# 1. Export separate gifs
# Ex: export "Export/character_idle.gif" and "Export/character_attack.gif"
aseprite -b "$aseprite_filepath" --save-as "temp/${file_basename}_{tag}.gif"
# 2. Convert each gif in temp folder to a png spritesheet
pushd temp > /dev/null
for gif_filepath in *.gif; do
# Ex: "character_idle"
animation_file_basename=${gif_filepath%.*}
# Mute spritesheet metadata json output
# If you need it, you can add --data "${animation_file_basename}_spritesheet.json" instead
aseprite -b "$gif_filepath" --sheet "${animation_file_basename}_spritesheet.png" > /dev/null
done
popd > /dev/null
# 3. Move all spritesheets to Export folder
mkdir -p Export
mv temp/*.png Export/
# Clean up temp dir
rm -rf temp