This is a common problem I've seen made, you are most likely printing the image, into the html page, rather than using an img src tag.
Try the following (assuming you're using CGI.pm)
image.html
<!-- image.html -->
<img src="/cgi-bin/view_image.pl?image=123">
and view_image.pl
#!/usr/bin/perl
# view_image.pl
use strict;
use warnings;
use DBI;
use CGI;
my $q = CGI->new();
my $dbh = DBI->connect(....);
# db setup stuff here
my $sth = $dbh->prepare("SELECT image_blob FROM images WHERE image=?")
+;
my $result = $sth->execute($q->param('image'));
if ($result && $result->rows()) {
my $image_blob = $result->fetchrow_array();
print $q->header( -type => 'image/jpeg' );
print $image_blob;
exit;
}
Note, this code is untested, but I do something similar
with images, using
Mason
under mod_perl