Problem with image handling

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SaeedGh
Forum Newbie
Posts: 2
Joined: Thu Aug 13, 2009 8:47 am

Problem with image handling

Post 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.
Attachments
gd-test.png
gd-test.png (287 Bytes) Viewed 89 times
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

Re: Problem with image handling

Post 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.
SaeedGh
Forum Newbie
Posts: 2
Joined: Thu Aug 13, 2009 8:47 am

Re: Problem with image handling

Post 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.
Post Reply