diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-08-19 03:12:28 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-08-19 03:12:28 +0000 |
commit | 1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch) | |
tree | 64c8c96cf54d8718847339a403e5e67b922e8c3f /editor/pnmflip | |
download | netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip |
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pnmflip')
-rwxr-xr-x | editor/pnmflip | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/editor/pnmflip b/editor/pnmflip new file mode 100755 index 00000000..6149aaa2 --- /dev/null +++ b/editor/pnmflip @@ -0,0 +1,80 @@ +#!/usr/bin/perl -w + +#============================================================================ +# This is a compatibility interface to Pamflip. +# +# It exists so existing programs and procedures that rely on Pnmflip +# syntax continue to work. You should not make new use of Pnmflip and +# if you modify an old use, you should upgrade it to use Pamflip. +# +# The one way that Pamflip is not backward compatible with Pnmflip is +# that with Pnmflip, you can do this: +# +# pnmflip -xy -tb +# +# and that causes pnmflip to do both transformations (i.e. the same thing +# as -r270). With Pamflip, you can't specify multiple (or zero) flip +# type options. Instead, you would use the -xform option: +# +# pamflip -xform=transpose,topbottom +# +#============================================================================ + +use strict; +use File::Basename; +use Cwd 'abs_path'; + +my $xformOpt; +my @miscOptions; +my $infile; + +$xformOpt = '-xform='; # initial value + +@miscOptions = (); + +foreach (@ARGV) { + if (/^-/) { + # It's an option + if (/^-lr$/ || /^-le.*$/) { + $xformOpt .= "leftright,"; + } elsif (/^-tb$/ || /^-to.*$/) { + $xformOpt .= "topbottom,"; + } elsif (/^-x.*$/ || /^-tr.*$/) { + $xformOpt .= "transpose,"; + } elsif (/^-r9.*$/ || /^-rotate9.*$/ || /^-cc.*$/) { + $xformOpt .= "transpose,topbottom,"; + } elsif (/^-r1.*$/ || /^-rotate1.*$/) { + $xformOpt .= "leftright,topbottom,"; + } elsif (/^-r2.*$/ || /^-rotate2.*$/ || /^-cw$/) { + $xformOpt .= "transpose,leftright,"; + } else { + # It's not a transformation option; could be a Netpbm common + # option. + push(@miscOptions, $_); + } + } else { + # It's a parameter + if (defined($infile)) { + print(STDERR + "You may specify at most one non-option parameter.\n"); + } else { + $infile = $_; + } + } +} + +# Finish off the -xform option by removing any trailing comma + +$/ = ','; +chomp($xformOpt); + +my $infileParm = defined($infile) ? $infile : "-"; + +# We want to get Pamflip from the same directory we came from if +# it's there. Frequently, the directory containing Netpbm programs is +# not in the PATH and we were invoked by absolute path. + +my $my_directory = abs_path(dirname($0)); +$ENV{"PATH"} = $my_directory . ":" . $ENV{"PATH"}; + +exec("pamflip", @miscOptions, $xformOpt, $infileParm); |