{"id":365,"date":"2007-01-24T00:08:36","date_gmt":"2007-01-24T05:08:36","guid":{"rendered":"http:\/\/crazedmonkey.com\/blog\/programming\/unix-command-line-image-tiler-for-google-maps.html"},"modified":"2007-02-01T14:26:53","modified_gmt":"2007-02-01T19:26:53","slug":"google-tile-cutter","status":"publish","type":"post","link":"http:\/\/crazedmonkey.com\/blog\/programming\/google-tile-cutter.html","title":{"rendered":"Unix command-line tile cutter for Google Maps"},"content":{"rendered":"<p>When I released my new <a href=\"http:\/\/crazedmonkey.com\/toronto-transit-map\/\" title=\"Toronto transit map - TTC, GO Transit, VIVA, etc. all on one Google map!\">Toronto transit map<\/a> I promised to release some of the tools I used to create it.  Possibly the most useful tool I created is my command-line tile cutter.  True, there are other image tilers, such as <a href=\"http:\/\/mapki.com\/wiki\/Automatic_Tile_Cutter\" title=\"Automatic Tile Cutter - Google Mapki\">a Photoshop script<\/a> and a <a href=\"http:\/\/open.atlas.free.fr\/GMapsTransparenciesImgOver.php\">web-based tool which uses Google Maps<\/a>.  I don&#8217;t have Photoshop and find it slow, and the web-based tool is difficult to use even with small files, so I created my own tile cutter.<\/p>\n<p>My image tiler uses Free Software, is released under the GPL, and has the following features:<\/p>\n<ul>\n<li>Tiles most image formats, including GIF, JPEG, PNG and TIFF.<\/li>\n<li>Works on most flavours of Unix, including Mac OS X.<\/li>\n<li>Supports version 1 and version 2 zoom levels.<\/li>\n<li>Automatically calculates offsets for all zoom levels.<\/li>\n<li>Supports padding from the upper-left as output by the <a href=\"http:\/\/open.atlas.free.fr\/GMapsTransparenciesImgOver.php\">web-based tiling helper<\/a>.<\/li>\n<li>Automatically pads image to size appropriate to Google Maps (ie. multiple of 256).<\/li>\n<li>Optionally discards empty transparent tiles to save space.<\/li>\n<li>Optional prefix for each tile.<\/li>\n<li>Outputs tiles in PNG format.<\/li>\n<li>Compresses tiles with either <a href=\"http:\/\/advancemame.sourceforge.net\/comp-readme.html\">advpng<\/a> or <a href=\"http:\/\/pmt.sourceforge.net\/pngcrush\/\">pngcrush<\/a>.<\/li>\n<\/ul>\n<p>The tiler requires <a href=\"http:\/\/www.imagemagick.org\/\">ImageMagick<\/a> and <a href=\"http:\/\/advancemame.sourceforge.net\/comp-readme.html\">advpng<\/a> or <a href=\"http:\/\/pmt.sourceforge.net\/pngcrush\/\">pngcrush<\/a> for PNG compression. (I recommend advpng as it is faster and compresses smaller in most situations.) Tiled image size is restricted only by disk space and ImageMagick limitations.<\/p>\n<p>To use the tile cutter, one need only specify the image being tiled, the Google tile coordinates of the top-left tile, the zoom level for which those coordinates are valid and the zoom level the tile represents.  For example, suppose we have three images (<code>img15.png<\/code>, <code>img16.png<\/code> and <code>img17.png<\/code>) for zoom levels 15 through 17 (in version 2 zoom levels), respectively.  The top-left corner of the image at level 15 is 1812,1924.  You would then run the following commands to generate the tiles:<\/p>\n<pre><code title=\"Example using googletile to tile three images of differing zoom levels\">% googletilecutter -o 15 -t 1812,1924 -z 15 img15.png\r\n% googletilecutter -o 15 -t 1812,1924 -z 16 img16.png\r\n% googletilecutter -o 15 -t 1812,1924 -z 17 img17.png<\/code><\/pre>\n<p>Note that the only options which need to be changed from image to image are the zoom level of the image and the image itself.  Compression and discarding of empty tiles is performed automatically.  For more command-line options execute the script with the <code>-h<\/code> option.<\/p>\n<p><a href=\"http:\/\/crazedmonkey.com\/googletilecutter\/googletilecutter.sh\">Download the Unix command-line tile cutter for Google Maps<\/a>.  If you have any problems or experience any unexpected behaviour, please leave a comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When I released my new <a href=\"http:\/\/crazedmonkey.com\/toronto-transit-map\/\" title=\"Toronto transit map - TTC, GO Transit, VIVA, etc. all on one Google map!\">Toronto transit map<\/a> I promised to release some of the tools I used to create it. Possibly the most useful tool I created is my command-line tile cutter. True, there are other image tilers, such&nbsp;&hellip;&nbsp;<a class=\"read_more\" href=\"http:\/\/crazedmonkey.com\/blog\/programming\/google-tile-cutter.html\" rel=\"bookmark\" title=\"Continue reading &ldquo;Unix command-line tile cutter for Google Maps&rdquo;\"><span>Read more<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[27,2],"tags":[],"_links":{"self":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/posts\/365"}],"collection":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/comments?post=365"}],"version-history":[{"count":0,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/posts\/365\/revisions"}],"wp:attachment":[{"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/media?parent=365"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/categories?post=365"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/crazedmonkey.com\/blog\/wp-json\/wp\/v2\/tags?post=365"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}