split image into google map tiles

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
spiderplant0
Posts: 16
Joined: 2012-11-15T06:43:37-07:00
Authentication code: 6789

split image into google map tiles

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: split image into google map tiles

Post 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"
snibgo's IM pages: im.snibgo.com
spiderplant0
Posts: 16
Joined: 2012-11-15T06:43:37-07:00
Authentication code: 6789

Re: split image into google map tiles

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: split image into google map tiles

Post by snibgo »

Yes, among other differences. See http://www.imagemagick.org/Usage/windows/
snibgo's IM pages: im.snibgo.com
Post Reply