Jump to content

PHP Imagecreatetruecolor black background


fwilson789

Recommended Posts

This is a really weird problem.

 

So I start out by making the images:

$image = imagecreatefromjpeg("background.jpg"); // make background image from jpeg
$rectangle = imagecreatetruecolor(1000, 98); // make rectangle that will be semi-opaque (imagecopymerge)
$text = imagecreatetruecolor(1000, 98); // make text that should be on top of rectangle w/ transparent background

 

Whenever you use the imagecreatetruecolor() function, the resulting image has all black pixels for the background. To fix this, I just draw a rectangle over the entire created image and set the color to red. Following this, I call imagecopymerge($image, $rectangle,..., 50) This works wonderfully as I have a red rectangle on top of my main image that is 50% see-through.

 

The reason I want my text on a different image is so that it can be moved independently of the rectangle, and go out of it if necessary. I would also like the text to have a 75% opacity. The problem here is that I can't seem to make the background of the $text image transparent without it looking terrible. I allocated $black to black and used imagecolortransparent(). It worked, but there is a small black border around the text.

 

I know this may not be the most clear question in the world, but I had to write it quick.

 

I appreciate anyone's help very much.  ;D

 

Fred

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.