Skip to content

Instantly share code, notes, and snippets.

@chocomelonchan
Created May 12, 2014 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chocomelonchan/3f5f6dde1a32e9e34d35 to your computer and use it in GitHub Desktop.
Save chocomelonchan/3f5f6dde1a32e9e34d35 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -lt 3 ]; then
echo "Usage: append DIRECTION file1 file2 ... dest"
echo "i.e.: append -left 01.png 02.png dest.png"
echo "DIRECTION = [-left|-right|-top|-bottom]"
exit
fi
DIRECTION=$1
shift;
ARGS=("$@")
DEST=${ARGS[((${#ARGS[@]}-1))]}
FILES="${ARGS[@]:0:((${#ARGS[@]}-1))}"
case "$DIRECTION" in
"-left"|"-right") OPTIONS='+append';;
"-top"|"-bottom") OPTIONS='-append';;
esac
case "$DIRECTION" in
"-left"|"-top") FILES=`echo "$FILES" | awk '{for (i=NF; i>0; i--) printf("%s ",$i);print ""}'`;;
esac
convert $OPTIONS $FILES $DEST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment