Last active
May 31, 2021 01:37
-
-
Save BrandonRomano/8271e3af96cb3fcea9a4ca3501273e79 to your computer and use it in GitHub Desktop.
Aseprite Compile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Compiles an entire directory of .aseprite files | |
# down to PNGs in another directory. | |
# | |
# $1: The input directory (aseprite files) | |
# $2: The output directory (pngs) | |
# | |
# If you're not on a standard Mac install, you can overwrite | |
# ASEPRITE_PATH as an environment variable pointing to your | |
# aseprite command. | |
cd "$(dirname "$0")" | |
# Set ASEPRITE_PATH path if it's not set by an env variable | |
if [[ -z "$ASEPRITE_PATH" ]]; then | |
# If it's not set assume we're on a standard Mac install | |
ASEPRITE_PATH="/Applications/Aseprite.app/Contents/MacOS/aseprite" | |
fi | |
######################################### | |
# Compiles a single Aseprite file. | |
# | |
# $1: The location of the aseprite file | |
# $2: The output file | |
######################################### | |
Assets__export_file() { | |
mkdir -p $(dirname ${2}) | |
# Send this noisy output to hell | |
"$ASEPRITE_PATH" -b "$1" --sheet "$2" > /dev/null | |
} | |
######################################### | |
# Compiles a directory of Aseprite files | |
# to another directory of PNGs | |
# | |
# $1: The input directory containing Aseprite files | |
# $2: The output directory to export to PNGs | |
######################################### | |
Assets__export_dir() { | |
# A sed-friendly input & output | |
local inDir="$(echo "$1" | sed -e 's/[./&]/\\&/g')" | |
local outDir="$(echo "$2" | sed -e 's/[./&]/\\&/g')" | |
# Compile each file | |
for sourceFile in $(find "$1" -name '*.aseprite'); do | |
local outFile=$(echo "$sourceFile" | sed "s/$inDir/$outDir/g" | sed "s/\.aseprite$/\.png/g") | |
Assets__export_file "$sourceFile" "$outFile" | |
done | |
} | |
Assets__export_dir "$1" "$2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment