| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
############################################################################## |
| 4 |
# This is essentially a Perl program. We exec the Perl interpreter specifying |
| 5 |
# this same file as the Perl program and use the -x option to cause the Perl |
| 6 |
# interpreter to skip down to the Perl code. The reason we do this instead of |
| 7 |
# just making /usr/bin/perl the script interpreter (instead of /bin/sh) is |
| 8 |
# that the user may have multiple Perl interpreters and the one he wants to |
| 9 |
# use is properly located in the PATH. The user's choice of Perl interpreter |
| 10 |
# may be crucial, such as when the user also has a PERL5LIB environment |
| 11 |
# variable and it selects modules that work with only a certain main |
| 12 |
# interpreter program. |
| 13 |
# |
| 14 |
# An alternative some people use is to have /usr/bin/env as the script |
| 15 |
# interpreter. We don't do that because we think the existence and |
| 16 |
# compatibility of /bin/sh is more reliable. |
| 17 |
# |
| 18 |
# Note that we aren't concerned about efficiency because the user who needs |
| 19 |
# high efficiency can use directly the programs that this program invokes. |
| 20 |
# |
| 21 |
############################################################################## |
| 22 |
|
| 23 |
exec perl -w -x -S -- "$0" "$@" |
| 24 |
|
| 25 |
#!/usr/bin/perl |
| 26 |
############################################################################## |
| 27 |
# This is nothing but a compatibility interface for Pnmquant. |
| 28 |
# An old program coded to call Ppmquant will continue working because |
| 29 |
# this interface exists. All new (or newly modified) programs should |
| 30 |
# call Pnmquant or Pnmremap instead. |
| 31 |
# |
| 32 |
# In days past, Pnmquant and Pnmremap did not exist. Ppmquant did |
| 33 |
# the job of both Pnmremap and Pnmquant, but only on PPM images. |
| 34 |
############################################################################## |
| 35 |
|
| 36 |
use strict; |
| 37 |
|
| 38 |
sub doVersionHack($) { |
| 39 |
my ($argvR) = @_; |
| 40 |
|
| 41 |
my $arg1 = $argvR->[0]; |
| 42 |
|
| 43 |
if (defined($arg1) && (($arg1 eq "--version") || ($arg1 eq "-version"))) { |
| 44 |
my $termStatus = system('pnmquant', '--version'); |
| 45 |
exit($termStatus == 0 ? 0 : 1); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
doVersionHack(\@ARGV); |
| 50 |
|
| 51 |
use Getopt::Long; |
| 52 |
|
| 53 |
my @ppmquantArgv = @ARGV; |
| 54 |
|
| 55 |
Getopt::Long::Configure('pass_through'); |
| 56 |
|
| 57 |
my $validOptions = GetOptions('mapfile' => \my $mapfileopt); |
| 58 |
|
| 59 |
my $mapfileOptionPresent = ($validOptions && $mapfileopt); |
| 60 |
|
| 61 |
if ($mapfileOptionPresent) { |
| 62 |
system('pnmremap', @ppmquantArgv); |
| 63 |
} else { |
| 64 |
system('pnmquant', @ppmquantArgv); |
| 65 |
} |