chakkaln has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I have been trying hard to make a very simple Perl CGI script generate an image when opened in a browser but without success. I had written a perl cgi script (simpleImage.cgi) which generates an image (using the GD module). I have saved it in my working directory (not in cgi-bin) and tried to open it in the browser. What is surprising me is that the browser shows the code rather than the image which it was suppose to generate. I have made the simpleImage.cgi as executable but that dint serve the problem. Can any one please help me how to get the image by running this script from the browser (I have wasted more than a days time trying to figure out myself). I am including the code below. Am I doing any thing wrong.
simpleImage.cgi
#!/usr/local/bin/perl use GD; use CGI ':standard'; # This creates a Web GIF image on the fly # create a new image $im = new GD::Image(1000,100); # allocate some colors $white = $im ->colorAllocate(255,255,255); $black= $im ->colorAllocate(0,0,0); $red = $im ->colorAllocate(255,100,0); $blue= $im ->colorAllocate(0,150,255); $yellow= $im ->colorAllocate(255,200,0); $pink= $im ->colorAllocate(150,0,150); $im->filledRectangle(10,5,990,15,$pink); $im->arc(10,10,10,10,0,360,$black); $im->fill(10,10,$white); $im->arc(990,10,10,10,270,90,$black); $im->fillToBorder(990,10,$black,$pink); # Convert the image to GIF and print it on standard output #binmode STDOUT; print "Content-type: image/gif\n\n"; print $im->gif;
Many thanks
Nagesh
20050727 Cleaned up by Corion: Added formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl CGI problem. Help please!!!!
by davorg (Chancellor) on Jul 27, 2005 at 13:57 UTC | |
|
Re: Perl CGI problem. Help please!!!!
by jbrugger (Parson) on Jul 27, 2005 at 13:57 UTC | |
by chakkaln (Sexton) on Jul 27, 2005 at 14:03 UTC | |
|
Re: Perl CGI problem. Help please!!!!
by Fletch (Bishop) on Jul 27, 2005 at 14:00 UTC | |
by chakkaln (Sexton) on Jul 27, 2005 at 14:12 UTC | |
by cfreak (Chaplain) on Jul 27, 2005 at 14:21 UTC | |
by Iron (Scribe) on Jul 27, 2005 at 14:29 UTC | |
by chakkaln (Sexton) on Jul 28, 2005 at 00:13 UTC | |
by davorg (Chancellor) on Jul 28, 2005 at 11:14 UTC | |
by davorg (Chancellor) on Jul 27, 2005 at 14:16 UTC | |
by chakkaln (Sexton) on Jul 28, 2005 at 00:12 UTC |