in reply to Mixing HTML and GIF

You can't actually embed an image straight into your HTML. There are 2 ways to go about this:
  1. You have your IMG tag point to a separate CGI program that generates/serves the image on the fly. This is good for when the image is truly dynamic. Example:
    script1.cgi (this method will also work if the HTML is not dynamically generated):
    #!/usr/bin/perl -w use strict; print "Content-type: text/html\n\n"; print <<EOT; <html><head><title>Image Example<title></head> <body> <img src="script2.cgi?size=20"> </body> EOT
    script2.cgi
    #!/usr/bin/perl -w use strict; use CGI; use GD; my $cgi=new CGI; my $cgi_size=$cgi->param('size') || '50'; print "Content-type: image/gif\n\n"; my $gd=new GD::Image($cgi_size,$cgi_size); my $blue=$gd->colorAllocate(0,0,255); $gd->fill(0,0,$blue); print $gd->gif;
  2. Your CGI generating the HTML page varies the content of the IMG tag. This is good if you are pulling the image from a fixed set of pregenerated images.
    script3.cgi (assuming the images are named banner1.gif to banner8.gif)
    #!/usr/bin/perl -w use strict; my $rnd=int(rand()*8); my $img="images/banner".$rnd".gif"; print "Content-type: text/html\n\n"; print <<EOT; <html><head><title>Another Image Example<title></head> <body> <img src="$img"> </body> EOT