--- "Grierson, Garry (UK07)" <[EMAIL PROTECTED]> wrote:
> Iv just started my very first attempt at using GD to produce graphics and
> I'm confused. I have RTFM in fact iv read a few but I'm still confused.
>
> I'm using ActivePerl on an NT system, so I loaded in the GD module using
> PPM, set the binmode to STDOUT as specified in the manual and wrote a hunk
> of code that I think should produce a big rectangle (it's only a test!). I
> tried outputting in both PNG and JPEG format but it just appears as
> 'hieroglyphics' on the browser page, obviously this is being interpreted as
> text instead of graphical information.
> I'm sure I'm being stupid and missed something fundamental. Help please!
>
> The rest of the script deals with searching a database and extracting third
> year values, these will hopefully be used within the graph to show the
> respective cumulative results.
>
> The Code so far..
>
> print <<HTML_SCRIPT1;
> Content-type: text/html\n\n
[snip]
You can't print the jpeg directly in the Web page. What you need to do is have your
script
generate the HTML. Then, in the HTML, have an image tag that points to your script
with a
parameter that indicates that an image is to be displayed. In other words, the Web
page that you
display will have a link similar to the following:
<img src="/cgi-bin/myscript.cgi?action=image">
This will cause the browser to issue another GET request, this sending Query String
'action=image'
to your script. When your script reads that, it will do something like this:
my $action = param( 'action' ) || '';
if ( $action eq 'image' ) {
print header( 'image/jpeg' );
# rest of code here, though it's probably better to do
# a sub call
}
Cheers,
Curtis Poe
=====
Senior Programmer
Onsite! Technology (http://www.onsitetech.com/)
"Ovid" on http://www.perlmonks.org/
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/