What is happening is some html magic. The browser will automatically retreive an imageURL if it's in the html tag for the image, and it will end up in the browser's cache. So your cgi program is telling the client's browser to "look at this url" for an image, and the browser does it. So if you open this html file on your local machine, and open it in a browser, you will see the image, but the image is buried deep in the browser's catch.
<HTML>
<BODY>
<IMG SRC="http://www.zentara.net/anim_a_s_r.gif" HEIGHT=65 WIDTH=75 a
+lt="[zentara]" align=left>
</BODY>
</HTML>
So your cgi script does nothing but pass that url to the browser, it does not get the file.
The gobbldeeGook which you get when you use lwp to retreive the file, is the actual binary data of the image. You need to save it to a scalar( or a temp file) then run your image
info routine on it.
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;
use Image::Info qw(image_info dim);
my $data = get("http://www.learntogoogle.com/images/addform.jpg");
# this will print binary junk
#print "$data\n";
my $info = image_info( \$data );
if (my $error = $info->{error}) {
die "Can't parse image info: $error\n";
}
my($w, $h) = dim($info);
print "$w $h\n";
I'm not really a human, but I play one on earth.
flash japh
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.