in reply to Understanding GD.pm

I think you're a little confused about what you're trying to do.
If you wish to view the jpg image in your web-browser, you shouldn't open or print to the FILE file handle.
You also cannot print text and binary data at the same time.

If you just want to view the jpeg in the browser, change
print "Content-type: text/html\n\n";
to
print "Content-type: image/jpeg\n\n";
and then
print $newimage->jpeg;
Also don't print any text or anything else.

If you want to output a HTML page which contains an image, you must use the script to print out the HTML code, and in that code the IMAGE src href must point to a CGI which outputs only the image data (as above).

Hope this helps!

Replies are listed 'Best First'.
Re: Re: Understanding GD.pm
by cal (Beadle) on Oct 31, 2002 at 17:12 UTC
    Thanks for your help, I have commented out any reference to
    print "Content-type: text/html\n\n"; replacing the initial print header with print "Content-type: image/jpeg\n\n";
    using the line print $newimage->jpeg;
    Now I get an empty image with the "X"
      You said before that the script seemed to be stopping after you tried to make the new image from the old jpeg, which lines up with what you're seeing now. I'd suggest switching back to HTML output and changing the line to this:
      my $srcimage = GD::Image->newFromJpeg("churchmiddle.jpg") || print "GD +::Image->newFromJpeg('churchmiddle.jpg') failed: $!<br>\n";
      That should tell you a little more about what's going on.
      --

      Love justice; desire mercy.
        You know this is really getting me. The script still seems to stop printing right at that same line.
        my $srcimage = GD::Image->newFromJpeg("churchmiddle.jpg") || print "GD +::Image->newFromJpeg('churchmiddle.jpg') failed: $!<br>\n";