chromafilt.pl
569 Bytes
#!/usr/bin/perl -w
die "Usage: chromafilt.pl <basename of input sgi file> \n" unless $#ARGV==0;
$in = shift;
`./chromafilt $in`;
$out = sprintf("%snocrawl.rgb", $in);
open(FH, "+<$out") || die "Can't open $in: $!";
binmode(FH);
$info=sprintf("%s", `file $in.rgb`);
$info =~ /.*, (\d+) x (\d+), (1|2|3|4) channels/;
$w = $1;
$h = $2;
$c = $3;
$byte="";
read(FH, $byte, 12);
seek(FH, -1, 1);
printf FH "%c", $c;
close FH;
$skip = 512 + $w*$h*($c-1);
$cnt = $w*$h;
$infile=sprintf("%snorle.rgb", $in);
`dd if=$infile of=$out bs=1 skip=$skip seek=$skip count=$cnt`;