Jump to content

Problem with image handling


SaeedGh

Recommended Posts

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

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.