File: GrabImage

package info (click to toggle)
wmgrabimage 0.72-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 144 kB
  • ctags: 79
  • sloc: ansic: 489; makefile: 75; perl: 26
file content (69 lines) | stat: -rwxr-xr-x 1,921 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl

#
#    Grabs an image on the WWW and resizes it (with antialiasing) down so that it can be
#    displayed in a WindowMaker DockApp.

#    Need to give it the URL of the image like so;
#
#           GrabWeather http://whatever.com/image.gif
#


    require "ctime.pl";


    #
    #  Change to users home directory. We used to dump into /tmp
    #  but using home dir instead avoids multiple users interfering
    #  with one another. (Yeah, we could "unique-ize" the filenames, but
    #  this is easier for now...)
    #
    $home = (getpwuid($<))[7];
    $ok = chdir() || chdir($home);


    #
    #  Check to see if .wmGrabImage exists.
    #  If not, make it and move to it.
    #
    if ( !(-e ".wmGrabImage") ){
	mkdir(".wmGrabImage", 0775);
    }
    chdir(".wmGrabImage");





    $URL       = $ARGV[0];
    $Geometry  = $ARGV[1];
    $ImageName = $URL;
    $ImageName =~ s/.*\/(.*)$/\1/;
    if ($URL =~ /^file:\/\//) {

	$ImagePath = $URL;
	$ImagePath =~ s+file://(.*)+\1+;
	system("cp $ImagePath $home/.wmGrabImage/$ImageName");

    } else {


        #
        #  I think some of these wget command line options may cause problems
        #  for some people? Dont know why...
        #
        $GrabCmd = "wget --proxy=off --passive-ftp --tries 0 -q -O $home/.wmGrabImage/$ImageName $URL";
        system "$GrabCmd";

    }


if (! ($Geometry eq "") ) {
    system "convert -crop $Geometry $home/.wmGrabImage/${ImageName} $home/.wmGrabImage/${ImageName}.tmp.gif" ;
    system "convert -geometry 54x54 $home/.wmGrabImage/${ImageName}.tmp.gif ${home}/.wmGrabImage/${ImageName}.tmp.xpm";
} else {
    system "convert -geometry 54x54 $home/.wmGrabImage/${ImageName} ${home}/.wmGrabImage/${ImageName}.tmp.xpm";
}
    system "cat ${home}/.wmGrabImage/${ImageName}.tmp.xpm | sed -e \"s/Transparent/Black/\" \> ${home}/.wmGrabImage/${ImageName}.xpm; rm ${home}/.wmGrabImage/${ImageName}.tmp.xpm";