Page 1 of 1

Problem with image handling

Posted: Thu Aug 13, 2009 9:07 am
by SaeedGh
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?

Code: Select all

<?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.

Re: Problem with image handling

Posted: Thu Aug 13, 2009 9:51 am
by SidewinderX
Your code looks fine, it is probably a PHP configuration issue. I had a similar issue, but imagettftext only displayed in yellow - the solution was to recompile php with the correct configuration.

Re: Problem with image handling

Posted: Thu Aug 13, 2009 10:19 am
by SaeedGh
SidewinderX wrote:Your code looks fine, it is probably a PHP configuration issue. I had a similar issue, but imagettftext only displayed in yellow - the solution was to recompile php with the correct configuration.
:(
Yes, i think that it is best way in this situation.
Thank you.