#!/bin/bash

# change tile background color (#FFFFFF) from glosm-tiler to transparent
# WARNING!!! default background is #7F7F7F

# path to stored tiles
tilesPath="/SET/YOUR/PATH/TO/TILES/"
echo -e "Deleting empty PNG files in \"${tilesPath}\", please wait..."
find ${tilesPath} -type f -size 758c -print0 | xargs -0 -I xx rm -f  xx
echo -e "Deleting empty directories"
find ${tilesPath} -depth -empty -type d -exec rmdir {} \;
echo -e "Changing background in \"${tilesPath}\", please wait..."
find ${tilesPath} -name "*.png" -print0 | xargs -0 -I xx convert xx -alpha on -fuzz 20% -transparent '#FFFFFF' xx
echo -e "Done"
