Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get image size from a gif etc.

Status
Not open for further replies.

redgenie

Programmer
Aug 10, 2000
36
GB
I know I'm doing something wrong but could anyone point me to what it is. I'm trying to get the size attributes from a .gif using the code shown below (I think it's something to do with how I'm passing $imageData into imgsize):

Code:
use HTTP::Request;
use LWP::UserAgent;
use Image::Size;

my $ua = LWP::UserAgent->new(timeout => 30);
my $request = HTTP::Request->new(GET => "[URL unfurl="true"]http://somewhere.com/image.gif");[/URL]

my $response = $ua->request($request);
my $imageData = $response->content_type();

my ($imageWidth, $imageHeight) = imgsize($imageData);

$imageWidth and $imageHeight are always empty.

Thanks for any info...
 
Oopps,

I corrected $response->content_type(); to $response->content();

That was a typo...


Code:
use HTTP::Request;
use LWP::UserAgent;
use Image::Size;

my $ua = LWP::UserAgent->new(timeout => 30);
my $request = HTTP::Request->new(GET => "[URL unfurl="true"]http://somewhere.com/image.gif");[/URL]

my $response = $ua->request($request);
my $imageData = $response->content();

my ($imageWidth, $imageHeight) = imgsize($imageData);
 
Sorted it, just needed to pass the reference to imgsize(\$imageData)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top