Scott R. Godin wrote:

Owen wrote:

--------------------------insert---------------------------
    open (OUT,">GD.png");
                my $img = $image->png;
    print OUT "$img";
--------------------------end insert---------------------------


It worked for me, try modifying the script a la above and see if it produces a GD.png file


indeed.

#!/usr/bin/perl
use warnings;
use strict;
use GD;

my $image = GD::Image->new(100,50);
my $white = $image->colorAllocate(128,128,255);
#$image->transparent($white);

my $fontcolor = $image->colorAllocate(0,0,0);
my $font = GD::Font->Small();

print "Content-type: image/png\n\n";
$image->string($font,2, 8,">hello world...",$fontcolor);
$image->string($font,2,20," Would you like",$fontcolor);
$image->string($font,2,32," to play a game?",$fontcolor);

my $img = $image->png or die "$!";
binmode STDOUT;
print $img;

apparently it's necessary to extract it to a scalar first; plus this way you can test for whether the method is supported in the compiled libgd and error if not,

$ perl gif.pl > gif.gif
libgd was not built with gif support
        ...propagated at gif.pl line 19.

#!/usr/bin/perl

use strict;
use warnings;
use GD;

my $image = GD::Image->new(100,50);
my $white = $image->colorAllocate(255,255,255);
$image->transparent($white);

my $fontcolor = $image->colorAllocate(0,0,0);
my $font = GD::Font->Small();

$image->string($font,2,10,'hello world',$fontcolor);
my $png = $image->png or die $!;
binmode STDOUT;
print $png;

$ ./gdtest.pl
No such file or directory at ./gdtest.pl line 15.
$

That is the $! on line 15 so it looks like we're getting closer ;p

I should've died before :)

So I'm assuming its a temp file of some kind, have to search teh guts more to find out what that means. Any ideas?

or,

"The image 'http://localhost/cgi-bin/hello.cgi' cannot be displayed, because it contains errors." ;) (yes that works, try it with the above code, which should work fine and display an image. :)

Add a content type header and it will work in your browser :)


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to