Problem with Image::Info

G

Gary

I am trying to write a perl cgi script using Image::Info. The problem
is
I am not getting any info from Image::Info. The hash comes back
empty.
If I reduce my script down to what is shown below the page that gets
displayed
only has the photo. If the hash wasn't empty "Good" should be
displayed above
the photo. I have never used Image::Info before. I am using the
module
description in CPAN, there are no error messages in the browser
error log and the page is being displayed. Are there any suggestions?

Gary

#!/usr/bin/perl -w
use strict;
use CGI qw:)standard);
use Image::Info qw(image_info dim);

my $Photo = param('photo');
my $info = image_info("$Photo");

print header;
print start_html(-title=>'My Photos', -bgcolor=>'#FFDEAD');

if (%info){
print "Good <br> \n";
}

print "<img SRC=\"$Photo\"/>",
print end_html;
 
B

Brian Wakem

Gary said:
#!/usr/bin/perl -w
use strict;
use CGI qw:)standard);
use Image::Info qw(image_info dim);

my $Photo = param('photo');
my $info = image_info("$Photo");

print header;
print start_html(-title=>'My Photos',  -bgcolor=>'#FFDEAD');

if (%info){
print "Good <br> \n";
}

print "<img SRC=\"$Photo\"/>",
print end_html;


$ perl tmp119.pl
Global symbol "%info" requires explicit package name at tmp119.pl line 12.
Execution of tmp119.pl aborted due to compilation errors.


I assume $info is a reference to a hash, in which case you need to read
perldoc perlref
 
J

Joe Smith

Gary said:
#!/usr/bin/perl -w

#!/usr/bin/perl
use warnings;
use strict;
use CGI qw:)standard);
use Image::Info qw(image_info dim);

my $Photo = param('photo');
my $info = image_info("$Photo");

print header;
print start_html(-title=>'My Photos', -bgcolor=>'#FFDEAD');

if (%info){
print "Good <br> \n";
}
print "<img SRC=\"$Photo\"/>",
print end_html;

print h1("No photo name specified") unless $Photo;
print h1("File '$Photo' does not exist in this directory
on the server") unless -f $Photo;
if ($info) {
print img({img=>$Photo,alt=>$Photo}), start_ul();
print li(b($_)," = $info->{$_}") for sort keys %$info;
print end_ul();
} else {
print h1("Unable to get image_info from '$Photo'");
}


That last part needs
use CGI qw:)standard *ul);


-Joe
 
D

Dr.Ruud

Joe Smith schreef:
print h1("No photo name specified") unless $Photo;
print h1("File '$Photo' does not exist in this directory
on the server") unless -f $Photo;

s/print/die/g
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top