Andrew Gaffney wrote:
I wrote my own script based off your example and the docs at <http://search.cpan.org/~lds/GD-2.11/GD.pm>. When I run the below program, I get:


skyline skyline-src # ./genbutton.pl gd-png: fatal libpng error: Invalid number of colors in palette gd-png error: setjmp returns error condition


Here is my code:



#!/usr/bin/perl


use warnings;
use GD;

$im = new GD::Image->new(51, 20);

$gray  = $im->colorClosest(127, 127, 127);
$blue = $im->colorClosest(0, 0, 127);
$white = $im->colorClosest(255, 255, 255);
$black = $im->colorClosest(0, 0, 0);
$im->transparent($white);

$im->filledRectangle(0, 0, 51, 20, $white); # Transparent background fill

By putting in a bunch of print and die statements, I've determined the problem is at the line above. I still get the error if I comment out the line that sets white as transparent above.


$im->filledRectangle(4, 4, 51, 20, $gray);
$im->filledRectangle(0, 0, 47, 16, $blue);
$im->string(gdSmallFont, 3, 3, "Test", $black);

open(PNG,"> /home/httpd/htdocs/testbutton.png") or die "Can't write GDtest.png: &!\en";
binmode (PNG);
print PNG $im->png;
close(PNG);




--
Andrew Gaffney


-- 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