Jump to content

Small GD problem


martian2k4

Recommended Posts

Hey all, I am using GD and it all works ok exept for the color of the text is a blue (Like the color of the image for the background) but it should be white.

<?php
header("Content-type: image/png");
$string = "TESTING";
$im = imagecreatefrompng("images/1.png");
$white = imagecolorallocate($im, 255, 255, 255);
$px = (imagesx($im) - 7 * strlen($string)) / 2;
imagestring($im, 3, $px, 15, $string, $white);
imagepng($im);
imagedestroy($im);
?>

Is the code. Could some one tell me whats wrong? Thanks
Link to comment
https://forums.phpfreaks.com/topic/30661-small-gd-problem/
Share on other sites

Hmmm, I made a slight modification to it to run on my machine without your 1.png file and the text is infact white for me...
Can you run the script, save the image and check what hex the colour is with a graphics package?

Just for reference, the modifications made were:
[code]<?php
header("Content-type: image/png");
$string = "TESTING";
$im = imagecreate(800,600);
$bg = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
$px = (imagesx($im) - 7 * strlen($string)) / 2;
imagestring($im, 3, $px, 15, $string, $white);
imagepng($im);
imagedestroy($im);
?>[/code]
Is the text white when you run that?
Link to comment
https://forums.phpfreaks.com/topic/30661-small-gd-problem/#findComment-141286
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.