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: PHP: 5.2 GD: 2.2 (all features is enable) (image is attached) Thank you very much.
Gah I just had this problem like a week ago but I don't remember what I did to fix it. I'll tell you if I remember.
Probably need to clear your cache, it probably still has an old version you did in the browser cache on the old host cuz that code clearly allocates white.
Compare what the following returns <?php var_dump(gd_info()); ?> And check imagecolorallocate and imagefill return values.
Please remember! I cleared cache and even used of another web browser. then change the script's name and... This is result of var_dump(gd_info()): array(12) { ["GD Version"]=> string(27) "bundled (2.0.34 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(true) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(true) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) } Code (markup): imagecolorallocate return: 16777215 imagefill return: 1 I test a simpler code: <?php $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); header ('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> PHP: Just is BLACK! even if change RBGs. 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!