Professional Web Applications Themes

Image::Magick scalar value to print use CGI - PERL Modules

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 ...

  1. #1

    Default Image::Magick scalar value to print use CGI

    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; cht=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>

    brainbend Guest

  2. #2

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

    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: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
    Gunnar Hjalmarsson Guest

Similar Threads

  1. Image::Magick newbie
    By Ananth Chellappa in forum PERL Modules
    Replies: 0
    Last Post: September 6th, 02:19 AM
  2. Image magick palette
    By kkarma in forum PERL Modules
    Replies: 0
    Last Post: July 31st, 03:16 AM
  3. Image::Magick and padding of image
    By Lars Haugseth in forum PERL Modules
    Replies: 0
    Last Post: February 5th, 07:17 PM
  4. Image Magick
    By Kae Verens in forum PHP Development
    Replies: 4
    Last Post: January 9th, 07:06 PM
  5. [PHP] Image Magick
    By David T-G in forum PHP Development
    Replies: 0
    Last Post: August 26th, 10:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139