Page 1 of 1

split image into google map tiles

Posted: 2013-03-09T14:35:54-07:00
by spiderplant0
I have a 2304 x 3584px image that I want to split up into 126 256x256 tiles.
I figured out how to do this...

convert -crop 256x256 t2_gmd_z8.bmp out2\tile.png

...but I cant figure out how to incorporate the x & y coordinate in the file name.

The big image's top left corner is google coords (121,73) so I want the tiles to be generated as:
tile_121_73.png, tile_122_73.png, .....

I have read the chapter: http://www.imagemagick.org/Usage/crop/#crop_tile
which suggests using fx but I cant get this to work.
Could someone supply me with the command I should use please.

Re: split image into google map tiles

Posted: 2013-03-09T14:57:34-07:00
by snibgo
Windows script; adjust for other shells:

Code: Select all

convert -size 2304x3584 xc:White test.png

convert test.png -crop 256x256 ^
  -set filename:tile "%%[fx:page.x/256+121]_%%[fx:page.y/256+73]" ^
  +repage +adjoin "tile_%%[filename:tile].png"

Re: split image into google map tiles

Posted: 2013-03-10T05:17:32-07:00
by spiderplant0
Thanks very much.
I guess that the manual has been written for linux users, and for windows we have to double up the percent signs.

Re: split image into google map tiles

Posted: 2013-03-10T05:32:12-07:00
by snibgo
Yes, among other differences. See http://www.imagemagick.org/Usage/windows/