I know that question is little old, but I wrote script that is using JRW solution. Script is splitting image file into series of images of given size:
#!/bin/bash
FILE=$1
FILENOEXT=${FILE%.*}
SLICEWIDTH=$2
WIDTH=`file $FILE | cut -f5 -d" "`
NUMOFSLICES=`echo "scale=2; $WIDTH/$SLICEWIDTH+1" | bc`
for i in `seq $NUMOFSLICES`
do
LAST=$(($SLICEWIDTH * $i - $SLICEWIDTH))
pngtopnm $FILE | pnmcut -left $LAST -width $SLICEWIDTH | pnmtopng > cropped-$FILENOEXT-$i.png
done
pngtopnm $FILE | pnmcut -left $LAST | pnmtopng > cropped-$FILENOEXT-$i.png
Argument one is filename and second width of chunk. In most cases the script return error on last chunk, but after that last chunk is cropped outside loop again and everything is ok… :)
$ convert source.png -crop 1024x1024 destination.png
– Eimantas Apr 05 '11 at 13:17