tags:

views:

193

answers:

2

I have an image which is 1280 x 1664 and I want to use the ScrollViewSuite example that Apple gives us but I need to cut this image up to multiple zoom levels.

So, does anybody know how I can tile an image at multiple zoom levels. There must be an easy way to tilling an image to 256x256 without cutting it by hand via photoshop?

+1  A: 

Funny -- I went to bed last night knowing this was the first thing I'd have to address this morning. I just found a remarkably simple solution to this. ImageMagick out of the box using convert with the -crop option:

convert bigimage.png -crop 256x256 tile.png

This makes as many tile files as necessary and most importantly creates rectangles on the right side and bottom.. all of the other solutions I explored made n,m evenly sized tiles out of the image.

The tiles are numbered tile-##.png where ## starts at zero. I'd have preferred -row#-col#.png, but this will work for me. CATiledLayer, here I come.

Quinn
Peter's solution that includes column and row information in the filenames is genius. I made a little shell script to rename the filenames, but this is so much more elegant. Works great. Thanks for sharing!
Quinn
+3  A: 

Hi Quinn, great find. I did a bit of researching from what you found and I've managed to add the row and col to the output filename. I've also resized the image to what percentage I want the image to be. So I can now do it all from 1 large image.

convert bigimage.png -resize 25% -crop 256x256 -set filename:tile "%[fx:page.x/256+1]_%[fx:page.y/256+1]" +repage +adjoin "tile_25_%[filename:tile].png"

Thanks a lot for helping me out, its saved me a lot of time. Hopefully I've helped you out?

Peter