Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.