#!/bin/sh

image="left-blank.png"
zoomlevel="17"

# dont change anything below


mkdir $zoomlevel 2>/dev/null

xres=`identify -format %w $image`
yres=`identify -format %h $image`

xsize=256
ysize=256

xtiles=`echo "$xres/$xsize"|bc`
ytiles=`echo "$yres/$ysize"|bc`

for y in `seq -s" " 1 $ytiles`
do
  for x in `seq -s" " 1 $xtiles`
  do
   xoffset=`echo "$x*($xsize-1)"|bc`
   yoffset=`echo "$y*($ysize-1)"|bc`
   mkdir ${zoomlevel}/${x} 2>/dev/null
   echo convert -crop ${xsize}x${ysize}+$xoffset+$yoffset $image image-${x}-${y}.png 
   convert -crop ${xsize}x${ysize}+$xoffset+$yoffset $image ${zoomlevel}/${x}/${y}.png 
  done
done




