http://packetstormsecurity.org/UNIX/admin/xscreensaver-4.04.2.tar.gz
[xscreensaver] / hacks / vidwhacker
index dbe6e327348fa027d5565d681997737571afa6b7..688895b8e323dda278831496ed81059c16e09d97 100755 (executable)
@@ -21,7 +21,7 @@ use diagnostics;
 use strict;
 
 my $progname = $0; $progname =~ s@.*/@@g;
-my $version = q{ $Revision: 1.18 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/;
+my $version = q{ $Revision: 1.20 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/;
 
 my $verbose = 0;
 my $use_stdin = 0;
@@ -54,6 +54,10 @@ my @displayer_programs = (
 # "xsri       -scale -keep-aspect -center-horizontal -center-vertical",
 );
 
+# apparently some versions of netpbm call it "pamoil" instead of "pgmoil"...
+#
+my $pgmoil = (which("pamoil") ? "pamoil" : "pgmoil");
+
 
 # List of interesting PPM filter pipelines.
 # In this list, the following magic words may be used:
@@ -68,7 +72,7 @@ my @displayer_programs = (
 my @filters = (
   "ppmtopgm FILE1 | pgmedge | pgmtoppm COLORS | ppmnorm",
   "ppmtopgm FILE1 | pgmenhance | pgmtoppm COLORS",
-  "ppmtopgm FILE1 | pgmoil | pgmtoppm COLORS",
+  "ppmtopgm FILE1 | $pgmoil | pgmtoppm COLORS",
   "ppmtopgm FILE1 | pgmbentley | pgmtoppm COLORS",
 
   "ppmrelief FILE1 | ppmtopgm | pgmedge | ppmrelief | ppmtopgm |" .
@@ -110,7 +114,7 @@ my @filters = (
   " pnmflip -tb FILE3 | ppmnorm > FILE2 ; " .
   " pnmarith -multiply FILE1 FILE2",
 
-  "ppmshift 30 FILE1 | ppmtopgm | pgmoil | pgmedge | " .
+  "ppmshift 30 FILE1 | ppmtopgm | $pgmoil | pgmedge | " .
   "   pgmtoppm COLORS > FILE2 ; " .
   " pnmarith -difference FILE1 FILE2",
 
@@ -157,6 +161,19 @@ sub pick_displayer {
 }
 
 
+# returns the full path of the named program, or undef.
+#
+sub which {
+  my ($prog) = @_;
+  foreach (split (/:/, $ENV{PATH})) {
+    if (-x "$_/$prog") {
+      return $prog;
+    }
+  }
+  return undef;
+}
+
+
 # Choose random foreground and background colors
 #
 sub randcolors {
@@ -324,6 +341,7 @@ sub get_ppm {
 
       if    ($fn =~ m/\.gif/i)   { $cmd = "giftopnm < \"$fn\""; }
       elsif ($fn =~ m/\.jpe?g/i) { $cmd = "djpeg < \"$fn\""; }
+      elsif ($fn =~ m/\.png/i)   { $cmd = "pngtopnm < \"$fn\""; }
       else {
         error "unrecognized file extension on $fn";
       }