I am trying to get the width and height attributes of jpg's and gif's on a remote server. I have found Image::Size and LWP but am unable to put them together so that I can open an http path (e.g. http://wwwfoobar.com/dirname/dirname/dirname/images/111203.gif) and print out the image size. Any help would be appreciated including where I might go to read more on this. TIA

My first attempt that failed:

#!/usr/bin/perl
# The next few lines use the LWP (Library www perl) module
                # to read the files via http that each url points to.
                $the_url =
'http://wwwfoobar.com/dirname/dirname/dirname/images/111203.gif';
                use LWP::UserAgent;  # This will cover all of them!
                use URI::URL;
                use HTTP::Request;
                $hdrs = new HTTP::Headers(Accept => 'text/plain',
                                                                  User-Agent => 
'MegaBrowser/1.0');
                
                $url = new URI::URL($the_url);
                $req = new HTTP::Request(GET, $url, $hdrs);
                $ua = new LWP::UserAgent;
                $resp = $ua->request($req);
                
                if ($resp->is_success) {
                
                        # If connection is successful the contents of the file
                        # read will now go into the variable $file
                        $image =  $resp->content;
                        
                }
                else {

                        # If connection is not successful then make note of this       
         
                        #print $resp->message;
                        $image = "socket_failure";
                        $sf_exists = "true";
                }

     use Image::Size;
     ($globe_x, $globe_y) = imgsize($image);
     print $globe_x . " " . $globe_y;




-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to