Awesome, the FIRST response on that Thread is what I am trying to do.

Here is his comment, that I'm referring to:

###### Start his Comment....
I assume you mean "how do I have a CGI program called from an image and have the CGI program pipe an image back to the IMG tag for display"?

First off is the image tag. Nothing special here, it should looks just like a normal image tag except it calls your CGI and passes the apropriate parameters to it:

<img src="img_gen.cgi?size=100">

The interesting part is in your CGI. You need to return apropriate HTTP headers for the image (Content-Type: image/gif or whatever is apropriate). and then just pipe the image contents back. Here's a small CGI program that returns an image, its size based on the passed parameter
#!/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); binmode STDOUT; #just in case we're on NT print $gd->gif;

####### End his comment


Ok, that is KIND OF What I'm wanting to do.
However, I want to use an Image I've already created.
How do I do that?

Here is what I have done so far, to no avail:

This one is just testing, I'll add it to my script when it works
#!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard :cgi-lib); ReadParse(\%in); if ((defined($in{img}) && $in{img} != 1) || !defined($in{img})) { $image_file = qq~/home/user/home_dir/graphics/banners/FRHWeb_366_x +_60.gif~; open(IMG,"$image_file") or die "could not read image: $!"; binmode IMG; $image_file_code = <IMG>; close(IMG); print "Content-type:image/gif\n\n"; print $image_file_code; exit; } else { $image_file = qq~/home/user/home_dir/graphics/banners/FRHWeb_212_x +_60.gif~; open(IMG,"$image_file") or die "could not read image: $!"; binmode IMG; $image_file_code = <IMG>; close(IMG); print "Content-type:image/gif\n\n"; print $image_file_code; exit; }


That does not work.
I would really appreciate it if someone could help me.

Thanks,
Richard

In reply to Re: Re: Perl "image" question... by powerhouse
in thread Perl "image" question... by powerhouse

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.