开发者

ImageMagick. What is the correct way to dice an image into sub-tiles

开发者 https://www.devze.com 2023-01-16 05:35 出处:网络
What is the correct way to an dice an image into N x N sub-tile images? 开发者_运维技巧 Thanks, DougThanks,

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
0

精彩评论

暂无评论...
验证码 换一张
取 消