Skip to content

Instantly share code, notes, and snippets.

@hotzenklotz
Created March 5, 2013 21:17
Show Gist options
  • Save hotzenklotz/5094358 to your computer and use it in GitHub Desktop.
Save hotzenklotz/5094358 to your computer and use it in GitHub Desktop.
use imagemagick to merge all images in a folder to produce a spritesheet
#!/bin/bash
# use imagemagick to merge all images in a folder to produce a spritesheet
# use conver -append for vertical stacking and
# convert +append for horizontal
if [ $# -gt 0 ]
then
if [ $2 ]
then
ext="."$2; # the extension to iterate over for input files
else
ext=".png"; # default extension
fi
classname=$1"-sprite";
echo "Generating sprite file...";
convert *$ext +append ./$classname$ext;
echo "Sprite complete!"
else
echo -e "Provide at least 1 argument!\nbuildSprite.sh spriteName input_extension"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment