Image::Magick scalar value to print use CGI

Image::Magick scalar value to print use CGI

am 14.04.2006 04:09:06 von brainbend

Has anyone ever had a situation where you where printing a scalar to an
html page (use CGI qw(:standard HTML);) and the scalar would not print?
But you checked it on the command line and the scalar value printed to
the terminal and in the correct place within the html?

If you didn't that is ok - just ignore me, if you did what did you
do?

Here is my code
#!/usr/bin/perl
use Image::Magick;

use CGI qw(:standard HTML);
print header (),

start_html (-title => "test_img3", -bgcolor =>
"darkorange");

file_size();

print end_html ();

exit (0);



sub file_size{

my $image = new Image::Magick;

my $full = 'the_sgm.jpg';

$image->Read($full);

my $value = $image->Get('filesize');

print "flie size is : $value";

}



It prints to command line:

Content-Type: text/html; charset=ISO-8859-1




PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

xml:lang="en-US">test_img3

flie size is : 26599


But the 26599 does not show up when I print call the file in html





PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

xml:lang="en-US">test_img3

flie size is :

Re: Image::Magick scalar value to print use CGI

am 14.04.2006 05:17:32 von Gunnar Hjalmarsson

brainbend wrote:
>
> Here is my code
> #!/usr/bin/perl

Where are

use strict;
use warnings;

and, since you run the script as a CGI script

use CGI::Carp 'fatalsToBrowser';

> sub file_size{
> my $image = new Image::Magick;
> my $full = 'the_sgm.jpg';

When running a script via CGI, don't take for granted that the working
directory is the directory where the script is located.

> $image->Read($full);

What happens if you replace that line with:

my $err = $image->Read($full) and die $err;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl