If lhoward's answer isn't what you were looking for exactly (i am only assuming this because you said you were a perl newbie and you probably wouldn't have any GD knowledge if you were :) then this might be what you're looking for. Rather than using an

<img src="...">

tag, you could use an href to go to the perl script which will then display the specified image file like this

<a href="/cgi-bin/image.cgi?image=image.jpg">

In this way, you can have one script display all your images based on the filename in the URL, and each image will be displayed on a page with the same "Look and Feel" without having to write multiple pages.

#!/usr/bin/perl use strict; use CGI; my $cgi = new CGI; my $image = $cgi->param('image'); print "Content-type: text/html\n\n"; print "<html><head><title>$image</title></head>\n"; print "<body>\n"; print "<center>\n"; print "<img src=/images/$image><p>\n"; #The path here would obviously +be different according to where your images are at print "</center>\n"; print "</body>\n"; print "</html>\n";

In reply to Re: How can I use a CGI script to return an image? by xjar
in thread How can I use a CGI script to return an image? by Anonymous Monk

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.