4 # Grabs an image on the WWW and resizes it (with antialiasing) down so that it can be
5 # displayed in a WindowMaker DockApp.
7 # Need to give it the URL of the image like so;
9 # GrabWeather http://whatever.com/image.gif
17 # Change to users home directory. We used to dump into /tmp
18 # but using home dir instead avoids multiple users interfering
19 # with one another. (Yeah, we could "unique-ize" the filenames, but
20 # this is easier for now...)
22 $home = (getpwuid($<))[7];
23 $ok = chdir() || chdir($home);
27 # Check to see if .wmGrabImage exists.
28 # If not, make it and move to it.
30 if ( !(-e
".wmGrabImage") ){
31 mkdir(".wmGrabImage", 0775);
33 chdir(".wmGrabImage");
42 $ImageName =~ s/.*\/(.*)$/\
1/;
43 if ($URL =~ /^file:\/\
//) {
46 $ImagePath =~ s
+file
://(.*)+\
1+;
47 system("cp $ImagePath $home/.wmGrabImage/$ImageName");
53 # I think some of these wget command line options may cause problems
54 # for some people? Dont know why...
56 $GrabCmd = "wget --proxy=off --passive-ftp --tries 0 -q -O $home/.wmGrabImage/$ImageName $URL";
62 if (! ($Geometry eq "") ) {
63 system "convert -crop $Geometry $home/.wmGrabImage/${ImageName} $home/.wmGrabImage/${ImageName}.tmp.gif" ;
64 system "convert -geom 54x54 $home/.wmGrabImage/${ImageName}.tmp.gif ${home}/.wmGrabImage/${ImageName}.tmp.xpm";
66 system "convert -geom 54x54 $home/.wmGrabImage/${ImageName} ${home}/.wmGrabImage/${ImageName}.tmp.xpm";
68 system "cat ${home}/.wmGrabImage/${ImageName}.tmp.xpm | sed -e \"s/Transparent/Black/\" \> ${home}/.wmGrabImage/${ImageName}.xpm; rm ${home}/.wmGrabImage/${ImageName}.tmp.xpm";