4_8qya
Last Updated: February 25, 2016
·
1.504K
· timurkhafizov
Dafba1178ec11d38a7fb5bd09f57e6c0

Tiling images for Google Maps with Imagemagick

We have had a project with custom maps made upon Google Maps Engine.
GME requires us to tile images for dynamic load.
Let's imagine that we have only 1 zoom level and 1000x1000 image for it.

We decided to tile it to 250x250 images. Of course imagemagick totally covers all our needs. You can tile images as simple as:

convert image.jpg -crop 250x250 ./tiles/tile.jpg

In this case imagemagick will tile images and place it to tiles dir and name them as tile-0.jpg, etc.
But GME asks us to use another naming format:

tile_#{zoom_level}_#{x_coordinate}-#{y_coordinate}.jpg

You can either rename all tiles or use imagemagick built-in filename formatting.
We decided to use the second approach. So this is how we managed to tile image for maps:

convert image.jpg -crop 250x250 +gravity \
-set filename:tile ./tiles/tile_%[fx:page.x/250]-%[fx:page.y/250] \
%[filename:tile].jpg

Hope it helps you to save some time when tiling images for Google Maps

Say Thanks
Respond