#!/bin/bash

set -e
set -u

tilesize=20
svgdir=source/svg
pngdir=data

for subdir in tiles/common tiles/common/snake tiles/lab menus
do
    for x in $svgdir/$subdir/*.svg
    do
        filename=`basename $x`
        filepath=$pngdir/$subdir/${filename/svg/png}
        rsvg-convert $x -w $tilesize -h $tilesize -o $filepath
        pngcrush -q $filepath tmp && mv tmp $filepath
    done
done
