Front page | perl.beginners |
Postings from March 2002
Re: GD getBounds problem
Thread Previous
From:
zentara
Date:
March 21, 2002 04:34
Subject:
Re: GD getBounds problem
Message ID:
fdkj9u0i5ra7o90nr65hjulefofem3gq1p@4ax.com
On Wed, 20 Mar 2002 12:18:28 -0800, eleqtriq@eleqtriq.ws (Agustin Rivera) wrote:
>I have a problem. The code below creates the error below. I can't see what
>is wrong with it. I could of swore this code used to work.
>Any ideas?
>
>use GD;
>use LWP::Simple;
>use strict;
>### GET IMAGE ATTRIBS
><.. bunch of code that gets an image off the web and writes it to disk
>successfully ..>
>
>open(OUT, ">image.jpg") or die $!;
>binmode(OUT);
>print OUT $content;
>close(OUT);
>my $image=GD::Image->newFromJpeg("image.jpg");
>my ($width,$height)=$image->getBounds();
>
>Error:
>Can't call method "getBounds" on an undefined value at ./sendanf.pl line 32.
Well the code below runs fine. It seems you are wiping out
the jpg with the print OUT statement. When GD gets it,
it's no longer a jpg.
###############################################
#!/usr/bin/perl
use warnings;
use GD;
use LWP::Simple;
use strict;
#open(OUT, ">image.jpg") or die $!;
#binmode(OUT);
#print OUT my $content;
#close(OUT);
my $image=GD::Image->newFromJpeg("image.jpg");
my ($width,$height)=$image->getBounds();
print "$width\t$height\n";
###############################################33
Thread Previous