tools to create bordered cards in a sprite
[brisk-img.git] / bin / borderizer.sh
1 #!/bin/bash
2
3 if [ $# -ne 3 -o "$1" = "-h" -o "$1" = "--help" ]; then
4     echo "$0 <folder_in> <template_file> <suffix>"
5     exit 1
6 fi
7
8 fold=$1
9 tmpl=$2
10 sfx=$3
11
12 w=$(identify -format "%w" ${fold}/00${sfx}.png)
13 h=$(identify -format "%h" ${fold}/00${sfx}.png)
14
15 wt=$(identify -format "%w" "${tmpl}")
16 ht=$(identify -format "%h" "${tmpl}")
17
18 x=$(((wt - w) / 2))
19 y=$(((ht - h) / 2))
20
21 for card in $(seq 0 39); do
22     convert "$tmpl" $(printf "%s/%02d%s.png" "$fold" "$((seed * 10 + card))" "$sfx") \
23             -geometry +${x}+${y} -composite $(printf "%s/%02d_bord%s.png" "$fold" "$((seed * 10 + card))" "$sfx")
24 done