What is the correct way to an dice an image into N x N sub-tile images?
Thanks,
Doug
What is the correct way to an dice an image into N x N sub-tile images?
Thanks,
Doug
Thanks,
Actually I futzed a bit and came up with the correct imagemagick incantations.
Here's the tcsh version.
Dice an image into a 4 x 4 grid (resultant images numbered sequentual). The number system is interpreted as: col + row * nrows:
convert -crop 25%x25% image.png tile-prefix.png
Often it is desirable to remap the sequential numbering to row x column. For example if you are using CATiledLayer in an iOS app and will need to ingest the correct tiles for a given scale. Here's how:
while ( $i < $number_of_tiles )
while -> set r = `expr $i \/ 4`
while -> set c = `expr $i \% 4`
while -> cp tile-prefix-$i.png tile-prefix-${r}x${c}.png
while -> echo $i
while -> @ i++
while -> end