$infile=$ARGV[0]; if (!(-e $infile)) { print "File $infile does not exist\n"; exit; } $wsp=$ARGV[1]; $hsp=$ARGV[2]; if (!($wsp)) { print "Width split not specified...\n"; exit; } if (!($hsp)) { print "Height split not specified...\n"; exit; } $file="pnmfile"; $cmd="djpeg $infile > $file"; if (!(-e $file)) { print "File $file does not exist\n"; exit; } open(IN,$file); $r1=; $r2=; close IN; ($w,$h)=split(/\s+/,$r2); $ws=$w / $wsp; $ws=int($ws); $hs=$h / $hsp; $hs=int($hs); print "Height: $h by $hsp X $hs slices\nWidth: $w by $wsp X $ws slices\n\n"; print "Ok?\n"; $ans=; chop $ans; exit if ($ans ne "y"); $top=0; $endh=$hsp-1; $endw=$wsp-1; foreach $j (0 .. $endh) { $left=0; print "Loop: $j\n"; foreach $i (0 .. $endw) { print "Loop: $j $i\n"; $fn1="piece-" . $j . "-" . $i . ".pnm"; $fn2="piece-" . $j . "-" . $i . ".jpg"; $cmd="pnmcut -left $left -top $top -width $ws -height $hs $file > $fn1"; print "$cmd\n"; system($cmd); $cmd="cjpeg $fn1 > $fn2"; print "$cmd\n"; system($cmd); print "\n"; $left=$left+$ws; } $top=$top+$hs; } exit;