SaeedGh Posted August 13, 2009 Share Posted August 13, 2009 Hi, When i run this simple script in my new VPS, the background of image is black. in other hosts the background is white. what is my mistake in php configurations? <?php header ('Content-type: image/png'); $im = @imagecreatetruecolor(120, 20)or die('Cannot Initialize new GD image stream'); $bg_color = imagecolorallocate($im, 255, 255, 255); imagefill($im, 0, 0, $bg_color); $text_color = imagecolorallocate($im, 233, 14, 91); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); imagepng($im); imagedestroy($im); ?> PHP: 5.2 GD: 2.2 (all features is enable) (image is attached) Thank you very much. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/170088-problem-with-image-handling/ Share on other sites More sharing options...
wildteen88 Posted August 13, 2009 Share Posted August 13, 2009 The background color is defined by this line $bg_color = imagecolorallocate($im, 255, 255, 255); The color is set using RGB values. In your case you're setting the background color as white. For black use 0, 0, 0 instead of 255, 255, 255 Read the manual on using the imagecolorallocate function. Link to comment https://forums.phpfreaks.com/topic/170088-problem-with-image-handling/#findComment-897287 Share on other sites More sharing options...
SaeedGh Posted August 13, 2009 Author Share Posted August 13, 2009 Thank you. I know it. But the problem is that any RBG values cause to an unwanted Black background! When i use imagecolorallocate($im, 255, 255, 255) Or imagecolorallocate($im, 125, 183, 112) Or any different RBG, the background is just BLACK. :'( I believe that my new VPS is not configured correctly/completely. i installed last version of GD but it seems that it is not enough. Link to comment https://forums.phpfreaks.com/topic/170088-problem-with-image-handling/#findComment-897298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.