If no colors are allocated, then this function returns -1.
Checking $mycolor, I found that it was set to -1 for all 2553 possible RGB combinations.
Assumption: Because the string function received -1 for the color value, it used the (first|last|?) value in the image's existing palette, thus explaining why the text appeared in the same color as the box.
I then converted test.jpg to test.gif with an image editor, and changed $jpg to "test.gif". $mycolor received a positive value, and the text appeared in the chosen color.
I then tried an explicit GD::Image->newFromJpeg on test.jpg, to no avail. I also tried converting to test.png, also to no avail.
It appears that colorAllocate works correctly when starting with .gif images, but not for .jpg or .png.
In reply to Re^3: Perl GD problem with colors for text
by keszler
in thread Perl GD problem with colors for text
by natol44
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |