Chris92 Posted February 10, 2008 Share Posted February 10, 2008 Hi, I'm making a soort of label that has the day number and month on it with GD, one problem is I want to make the day number green which works fine but when I try setting the month to grey it just stays white. Here's the current code I'm using: <?php header("Content-type: image/Gif"); $im = imagecreatefromgif("back.gif"); $green = imagecolorallocate($back, 117, 144, 48); $grey = imagecolorallocate($back, 85, 85, 85); imagettftext($im, 18, 0, 11, 25, $green, 'CALIBRI.TTF', "{$_GET['q']}"); imagettftext($im, 14, 0, 10, 43, $grey, 'CALIBRI.TTF', "{$_GET['w']}"); imagegif($im); imagedestroy($im); ?> http://chrishmmens.freehostia.com/images/label.php?q=10&w=FEB I treid switching the green and grey variables around which caused the month to come up in grey but the day came up in white. I also treid setting the grey variable after the day number was set onto the images which stopped the image from showing up all together. Thanks for any help, Chris. Quote Link to comment https://forums.phpfreaks.com/topic/90393-gd-2-different-text-colours/ Share on other sites More sharing options...
Chris92 Posted February 10, 2008 Author Share Posted February 10, 2008 Solved! I simply put the colorallocate funtion inside of the funtion to set the string: <?php header("Content-type: image/Gif"); $im = imagecreatefromgif("back.gif"); imagettftext($im, 18, 0, 11, 25, imagecolorallocate($im, 117, 144, 48), 'CALIBRI.TTF', "{$_GET['q']}"); imagettftext($im, 14, 0, 10, 43, imagecolorallocate($im, 85, 85, 85), 'CALIBRI.TTF', "{$_GET['w']}"); imagegif($im); imagedestroy($im); ?> Quote Link to comment https://forums.phpfreaks.com/topic/90393-gd-2-different-text-colours/#findComment-463464 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.