Ask a Question related to PERL Beginners, Design and Development.
-
Matthew Galaher #1
getting remote image sizes with image::size lwp
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.
[url]http://wwwfoobar.com/dirname/dirname/dirname/images/111203.gif[/url]) 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;
Matthew Galaher Guest
-
How to find size (in bytes) of an image using the GD image resource?
I would like to be able to determine the size (in bytes) of a file and re-adjust before output. Is this possible? Norm -- Avatar hosting at... -
adjusting image sizes
it doesn't work because once the image loaded in the clip, the clip still conserve his beginning's property (height & widht) :( ademus@free.fr -
getting remote image size with Image::Size & LWP
Thank you for your patience and help bringing me up to speed on how to be a better user of this list. My previous post was my first. I am... -
Dragging Image onto canvas changes image size
when I create a new canvas say 8.5x11, then try to drag a 4x6 size image onto it, it is not 4x6 on the canvas. it is smaller, is there a way to make... -
different monitors, different image sizes?
By any chance has anyone ever had a problem like this? I'm baffled by the case of a client that insists in telling me that the images at her website... -
R. Joseph Newton #2
Re: getting remote image sizes with image::size lwp
Matthew Galaher wrote:
[snip--not yet relevant]> 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.
> [url]http://wwwfoobar.com/dirname/dirname/dirname/images/111203.gif[/url]) 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:
Please show us the code and results when you:
Test Image::Size in isolation, using a local image file of known properites. Include any error
messages, the clearly marked lines they refer to, and a description of what happens or doesn't when you
run it.
Make sure you have:
use strict;
use warnings;
at the top of your script. People are usually not willing to spend much time on you problem until you
do.
Test LWP in isolation, getting a known plain text file and reading out the contents. Include any error
messages, the clearly marked lines they refer to, and a description of what happens or doesn't when you
run it.
Make sure you have:
use strict;
use warnings;
at the top of your script. People are usually not willing to spend much time on you problem until you
do.
Joseph
R. Joseph Newton Guest



Reply With Quote

