Click here to get back home

Image::Magick scalar value to print use CGI

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Image::Magick scalar value to print use CGI brainbend 04-13-2006
Posted by brainbend on April 13, 2006, 10:09 pm
Please log in for more thread options


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

<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE html

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

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

<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"
xml:lang="en-US"><head><title>test_img3</title>

</head><body bgcolor="darkorange">flie size is : 26599</body></html>


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


<?xml version="1.0" encoding="iso-8859-1"?>

<!DOCTYPE html

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

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

<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"
xml:lang="en-US"><head><title>test_img3</title>

</head><body bgcolor="darkorange">flie size is : </body></html>


Posted by Gunnar Hjalmarsson on April 13, 2006, 11:17 pm
Please log in for more thread options


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

Similar ThreadsPosted
image magick through apt-get November 27, 2004, 5:48 pm
Image magick palette July 30, 2004, 9:16 pm
Image::Magick newbie September 5, 2005, 10:19 pm
Image Magick code help November 29, 2004, 12:14 pm
Image Magick code help December 3, 2004, 6:43 pm
Errror in mod Image::magick or something else? October 29, 2005, 4:53 am
ANNOUNCE: Image::Magick::Tiler V 1.00 February 22, 2005, 11:35 am
ANNOUNCE: Image::Magick::Chart V 1.01 June 13, 2005, 3:36 am
Problems Installing Image::Magick September 26, 2006, 3:35 pm
Reduce colors with Image::Magick July 6, 2007, 7:06 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap