#!/bin/ksh #The command line argument is the name of a .jpg file. #Cut out 9 squares of s x s pixels. #http://netpbm.sourceforge.net/doc/ n=3 s=100 #length of side of square PATH=/opt/sfw/netpbm/bin:$PATH #width and height in pixels of $1.jpg w=`jpegtopnm $1.jpg | pamfile | awk '{print $4}'` h=`jpegtopnm $1.jpg | pamfile | awk '{print $6}'` for row in 0 1 2 do for col in 0 1 2 do rm -f $row$col.png jpegtopnm $1.jpg | pamcut \ -left $(((w - n * s) / 2 - 1 + s * col)) \ -right $(((w - n * s) / 2 - 1 + s * (col + 1) - 1)) \ -top $(((h - n * s) / 2 - 1 + s * row)) \ -bottom $(((h - n * s) / 2 - 1 + s * (row + 1) - 1)) | pnmtopng > $row$col.png chmod 444 $row$col.png done done exit 0