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

    In reply to Re: Mixing HTML and GIF by lhoward
    in thread Mixing HTML and GIF by mt2k

    Title:
    Use:  <p> text here (a paragraph) </p>
    and:  <code> code here </code>
    to format your post, it's "PerlMonks-approved HTML":



  3. Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  4. Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  5. Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  6. Please read these before you post! —
  7. 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
  8. You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  9. Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  10. See Writeup Formatting Tips and other pages linked from there for more info.