blue_cowdawg has asked for the wisdom of the Perl Monks concerning the following question:
Hi folks,
What I'm trying to do is write a CGI script that will later
be referenced by a javascript sniglet to load a random
image from an inventory of images in a set directory.
The random selection part is working just fine, but what
is driving me crazy is the part where we send the images
to the browser is misbehaving. What further infuriates me
is I know I got this to work before so I know I'm probably
missing something fairly obvious. Here is the offending
sniglet of code:
use strict; use CGI qw/ :all /; use Image::Info; use GD; | | much handwaving for parts that already work fine. | my $imgStream; if ( $type eq 'PNG' ) { $imgStream = GD::Image->newFromPng($image); } else { $imgStream = GD::Image->newFromJpeg($image); } exec $0 if not $imgStream; print header(-type=>$mime); my $png_data = $imgStream->png; binmode STDOUT; print $png_data; close STDOUT; exit(0);
What I'm seeing at the browser is that oh-so-useful Error 500 error. Checking the server error logs I see:
If I play around with the script a little run it as a command line script the right data is being generated for the image and can be loaded by Eye Of Gnome just fine. It just doesn't seem to work as a CGI.[Tue Aug 7 14:21:59 2007] [error] [client 68.37.143.39] Premature end + of script headers: /home/bcdcweb/public_html/cgi-bin/sendRandomImage +.pl
What am I missing here???
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using GD in a CGI script to randomly select images fails...
by ikegami (Patriarch) on Aug 07, 2007 at 20:04 UTC | |
by blue_cowdawg (Monsignor) on Aug 07, 2007 at 20:11 UTC | |
|
Re: Using GD in a CGI script to randomly select images fails...
by moritz (Cardinal) on Aug 07, 2007 at 19:42 UTC | |
|
Re: Using GD in a CGI script to randomly select images fails...
by Cody Pendant (Prior) on Aug 07, 2007 at 21:59 UTC | |
|
SOLVED: Using GD in a CGI script to randomly select images fails...
by blue_cowdawg (Monsignor) on Aug 08, 2007 at 17:43 UTC |