merge_images (version 1.0)
You can also look at:
#! /usr/bin/perl
##############################################################################
#
# SYNTAX: merge_images outfile listfile
#
# DESCRIPTION: This utility sums the images listed in a file.
#
#
# VERSION: 1.0
#
# HISTORY: 0.0 -> 1.0 1999-05-07
# HISTORY: Converted from ksh to perl
#
# CALLS: $UTIL/log_entry
# CALLS: $UTIL/file_to_log
# CALLS: $UTIL/setup_parfile
# CALLS: $UTIL/ftool_test
# CALLS: $FTOOL/farith
#
##############################################################################
use File::Basename;
#$DEBUG = 1;
($outfile, $listfile) = @ARGV;
$UTIL = $ENV{"UTIL"};
$FTOOL = $ENV{"FTOOL"};
$scriptname = basename($0);
$old = "old.tmp";
if ( -s "$listfile" ) {
`$UTIL/log_entry "Summing the following images to produce $outfile"`;
`$UTIL/file_to_log $listfile`;
}
unlink $outfile;
open LISTFILE, "<$listfile";
@files = <LISTFILE>;
foreach $file (@files) {
chomp($file);
###################
# Debugging output
###################
if ( "$DEBUG" ) {
print "$scriptname: file=$file\n";
}
if ( -e "$outfile" ) {
####################
# Add the next file
####################
rename $outfile, $old;
`$UTIL/setup_parfile $FTOOL/farith.par infil1=$file \\
infil2=$old \\
outfil=$outfile \\
ops=ADD`;
unlink $outfile;
`$FTOOL/farith >stdout.log 2>stderr.log`;
`$UTIL/ftool_test farith $? $0 2 stdout.log stderr.log`;
}
else {
#####################################################
# This is the first file, so just copy it to outfile
#####################################################
system("cp $file $outfile");
}
}
unlink $old;
exit 0;