Re: JPEG and Perl
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 30 Aug 2005 12:02:02 -0700
CSUIDL PROGRAMMEr wrote:
> Folks
> I am new to perl
That's okay, because this question doesn't have anything to do with
Perl.
> ALl want to do is to display a image on my html page using perl .
> Here is my code
>
> #!/usr/bin/perl
> print "Content-type:image/jpeg\n\n";
Here you are telling the client (the webbrowser) that you're about to
send a JPEG - binary data.
> print " </html>";
> print "<body>";
Here, you start sending the client *text*, not a JPEG.
> print " <IMG SRC='emb.jpeg'> " ;
> print "</body>";
> print"</html>";
> Is it right or am i missing something
You are missing something. If you want to send an HTML page that
contains an image source link, as you seemed to do above, tell the
client you're sending HTML:
print "Content-type: text/html\n\n";
If you want to send *just* the actual JPEG file, not an HTML page that
contains a link to the file, send the actual file:
[UNTESTED]
if (! open my $img, '<', 'emb.jpeg') {
print "Content-type: text/plain\n\n";
print "Error attempting to open emb.jpeg: $!\n";
} else {
binmode $img;
print "Content-type: img/jpeg\n\n";
my $buffer;
while (my $bytes = read ($img, $buffer, 1024) {
print $buffer;
}
}
Hope this helps,
Paul Lalli
.
- References:
- JPEG and Perl
- From: CSUIDL PROGRAMMEr
- JPEG and Perl
- Prev by Date: Re: Perldoc on the web
- Next by Date: Re: Perldoc on the web
- Previous by thread: Re: JPEG and Perl
- Next by thread: JPEG and Perl
- Index(es):
Relevant Pages
|