chinamox has asked for the wisdom of the Perl Monks concerning the following question:

Most excellent monks-

I am trying to write a simple CGI program that will use the Image::Size module to display a given image’s dimensions to the user.

I have checked the archives using super-search and even though my code is basically the same as this code, I am still getting an error. Can someone please tell me what I am doing wrong here?

Thank you for your help,

-mox

PS: I checked, and yes all three modules are installed on my server.

#!/usr/bin/perl use strict; use warnings; use CGI; use LWP::Simple qw(get); use Image::Size qw(imgsize); my $url = 'A STRING TAKEN FROM PATH_INFO'; my $img = get($url); my ($width, $height) = imgsize(\$img); print "$url is ${width}x${height}\n"; my $q = new CGI; # create new CGI print $q->header, $q->start_html('Image measuring'), $q->('The size of your image is:'), $q->("$url is {$x}x{$y}\n"), $q->end_html;

UPDATE: For some reason beyond this humble monk's understanding, the cgi is now working. Thank you for your time and thoughts.

Replies are listed 'Best First'.
Re: Using LWP and Image::Size to measure an image...
by stonecolddevin (Parson) on Dec 19, 2006 at 04:57 UTC

    Um, what's the error?

    Image::Size, although I've never personally used it, looks like it would be the most logical choice to me. Give us your error and perhaps we can help you further.

    meh.

      Sorry, Apache's error log says I am getting: 'Premature end of script headers: /home/dirctory/subdirector/web/my.cgi'

      Could someone please translate "premature end of script headers for me?"

      Thanks,

      -mox
        Apache Checks the header of the file on the server to see if its close to the mime format.
        So your error could be because your printing something befor the header " print "$url is ${width}x${height}\n"; ".
        It can Aslo be a Perl Error That the code is malformed or has some problems.
Re: Using LWP and Image::Size to measure an image...
by gt8073a (Hermit) on Dec 19, 2006 at 14:35 UTC
    "Premature end of script headers" happens because of use strict; and $q->("$url is {$x}x{$y}\n"),
    You're using $x and $y without declaring them first.
    JJ