Skip to content

Instantly share code, notes, and snippets.

@mralext20
Last active March 25, 2020 01:41
Show Gist options
  • Save mralext20/3e14e1581f0a4373ffbcc1cc4af0dc5b to your computer and use it in GitHub Desktop.
Save mralext20/3e14e1581f0a4373ffbcc1cc4af0dc5b to your computer and use it in GitHub Desktop.
image=in.png
convert ${image} -resize "32x32!" -modulate 100,300,100 "single.png"
for ((z=2; z<= 8; z+=1))
do
height=$((z * 32))
convert ${image} -resize "${height}x${height}!" -modulate 100,300,100 "temp${z}.png"
if [ -d "${z}" ]
then
rm -dr $z
fi
mkdir $z
echo "spliting sprite sheet at zoom level ${z}"
xi=0
for ((x=0; x<height; x+=32))
do
xi=$((xi+1))
yi=0
for ((y=0; y<height; y+=32))
do
yi=$((yi+1))
convert "temp${z}.png" -crop "32x32+${x}+${y}" "$z/s${yi}-${xi}.png"
done
done
rm "temp${z}.png"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment