|
Packit |
78deda |
#!/bin/sh
|
|
Packit |
78deda |
|
|
Packit |
78deda |
##############################################################################
|
|
Packit |
78deda |
# This is essentially a Perl program. We exec the Perl interpreter specifying
|
|
Packit |
78deda |
# this same file as the Perl program and use the -x option to cause the Perl
|
|
Packit |
78deda |
# interpreter to skip down to the Perl code. The reason we do this instead of
|
|
Packit |
78deda |
# just making /usr/bin/perl the script interpreter (instead of /bin/sh) is
|
|
Packit |
78deda |
# that the user may have multiple Perl interpreters and the one he wants to
|
|
Packit |
78deda |
# use is properly located in the PATH. The user's choice of Perl interpreter
|
|
Packit |
78deda |
# may be crucial, such as when the user also has a PERL5LIB environment
|
|
Packit |
78deda |
# variable and it selects modules that work with only a certain main
|
|
Packit |
78deda |
# interpreter program.
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# An alternative some people use is to have /usr/bin/env as the script
|
|
Packit |
78deda |
# interpreter. We don't do that because we think the existence and
|
|
Packit |
78deda |
# compatibility of /bin/sh is more reliable.
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# Note that we aren't concerned about efficiency because the user who needs
|
|
Packit |
78deda |
# high efficiency can use directly the programs that this program invokes.
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
##############################################################################
|
|
Packit |
78deda |
|
|
Packit |
78deda |
exec perl -w -x -S -- "$0" "$@"
|
|
Packit |
78deda |
|
|
Packit |
78deda |
#!/usr/bin/perl
|
|
Packit |
78deda |
#============================================================================
|
|
Packit |
78deda |
# This is a compatibility interface to Pamflip.
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# It exists so existing programs and procedures that rely on Pnmflip
|
|
Packit |
78deda |
# syntax continue to work. You should not make new use of Pnmflip and
|
|
Packit |
78deda |
# if you modify an old use, you should upgrade it to use Pamflip.
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# The one way that Pamflip is not backward compatible with Pnmflip is
|
|
Packit |
78deda |
# that with Pnmflip, you can do this:
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# pnmflip -xy -tb
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# and that causes pnmflip to do both transformations (i.e. the same thing
|
|
Packit |
78deda |
# as -r270). With Pamflip, you can't specify multiple (or zero) flip
|
|
Packit |
78deda |
# type options. Instead, you would use the -xform option:
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
# pamflip -xform=transpose,topbottom
|
|
Packit |
78deda |
#
|
|
Packit |
78deda |
#============================================================================
|
|
Packit |
78deda |
|
|
Packit |
78deda |
use strict;
|
|
Packit |
78deda |
use File::Basename;
|
|
Packit |
78deda |
use Cwd 'abs_path';
|
|
Packit |
78deda |
|
|
Packit |
78deda |
my $xformOpt;
|
|
Packit |
78deda |
my @miscOptions;
|
|
Packit |
78deda |
my $infile;
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$xformOpt = '-xform='; # initial value
|
|
Packit |
78deda |
|
|
Packit |
78deda |
@miscOptions = ();
|
|
Packit |
78deda |
|
|
Packit |
78deda |
foreach (@ARGV) {
|
|
Packit |
78deda |
if (/^-/) {
|
|
Packit |
78deda |
# It's an option
|
|
Packit |
78deda |
if (/^-lr$/ || /^-le.*$/) {
|
|
Packit |
78deda |
$xformOpt .= "leftright,";
|
|
Packit |
78deda |
} elsif (/^-tb$/ || /^-to.*$/) {
|
|
Packit |
78deda |
$xformOpt .= "topbottom,";
|
|
Packit |
78deda |
} elsif (/^-x.*$/ || /^-tr.*$/) {
|
|
Packit |
78deda |
$xformOpt .= "transpose,";
|
|
Packit |
78deda |
} elsif (/^-r9.*$/ || /^-rotate9.*$/ || /^-cc.*$/) {
|
|
Packit |
78deda |
$xformOpt .= "transpose,topbottom,";
|
|
Packit |
78deda |
} elsif (/^-r1.*$/ || /^-rotate1.*$/) {
|
|
Packit |
78deda |
$xformOpt .= "leftright,topbottom,";
|
|
Packit |
78deda |
} elsif (/^-r2.*$/ || /^-rotate2.*$/ || /^-cw$/) {
|
|
Packit |
78deda |
$xformOpt .= "transpose,leftright,";
|
|
Packit |
78deda |
} else {
|
|
Packit |
78deda |
# It's not a transformation option; could be a Netpbm common
|
|
Packit |
78deda |
# option.
|
|
Packit |
78deda |
push(@miscOptions, $_);
|
|
Packit |
78deda |
}
|
|
Packit |
78deda |
} else {
|
|
Packit |
78deda |
# It's a parameter
|
|
Packit |
78deda |
if (defined($infile)) {
|
|
Packit |
78deda |
print(STDERR
|
|
Packit |
78deda |
"You may specify at most one non-option parameter.\n");
|
|
Packit |
78deda |
exit(10);
|
|
Packit |
78deda |
} else {
|
|
Packit |
78deda |
$infile = $_;
|
|
Packit |
78deda |
}
|
|
Packit |
78deda |
}
|
|
Packit |
78deda |
}
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# Finish off the -xform option by removing any trailing comma
|
|
Packit |
78deda |
|
|
Packit |
78deda |
$/ = ',';
|
|
Packit |
78deda |
chomp($xformOpt);
|
|
Packit |
78deda |
|
|
Packit |
78deda |
my $infileParm = defined($infile) ? $infile : "-";
|
|
Packit |
78deda |
|
|
Packit |
78deda |
# We want to get Pamflip from the same directory we came from if
|
|
Packit |
78deda |
# it's there. Frequently, the directory containing Netpbm programs is
|
|
Packit |
78deda |
# not in the PATH and we were invoked by absolute path.
|
|
Packit |
78deda |
|
|
Packit |
78deda |
my $my_directory = abs_path(dirname($0));
|
|
Packit |
78deda |
$ENV{"PATH"} = $my_directory . ":" . $ENV{"PATH"};
|
|
Packit |
78deda |
|
|
Packit |
78deda |
exec("pamflip", @miscOptions, $xformOpt, $infileParm);
|