ImageMagick. What is the right way to crop an image into subtypes

What is the correct way to copy an image as NN fragments of an image?

Thanks,
Doug

+3
source share
1 answer

Thanks,

Actually, I did a bit of work and came up with the right imagemagick spells.

Here is the tcsh version.

Draw an image in a 4 x 4 grid (resulting images with sequence number). The number system is interpreted as: col + row * nrows:

$ convert -crop 25%x25% image.png tile-prefix.png 

It is often desirable to reassign sequential numbering to the column of row x. For example, if you use CATiledLayer in an iOS application and you will need to use the correct fragments 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 
+5
source

All Articles