View Full Version : PHP generate image - problems with background transparency

03-27-2009, 05:57 PM

I've got this code generating an image with some specified text on top of a specified background. The background is a .png image whith a transparent background. However, the php-generated image does not have the transparent background as the original image had - it's filled with black instead.

The second picture is the original while the first is a screenshot of the php result:

header("Content-type: image/png");

$image = imagecreatefrompng("seddel.png");

//imagecolorallocate($image, R, G, B) in HEX values
$font_black = imagecolorallocate($image, 2, 1, 8);

$string = "your text 1";

//($image, fontsize, rightindent, downindent, data, txtcolour)
imagestring($image, 3, 7, 30, $string, $font_black);



Does anybody know why this is caused and how to fix it?

03-28-2009, 07:08 AM
PHP can't retain transparent backgrounds....

so you'll just have to edit it to white or something because currently PHP just makes they black :mad:

03-28-2009, 07:51 AM
Damn, that sucks :mad: But thanks, it makes scense now.

EDIT: There is not any other way to preserve transparency in PNG images while doing what I want?
Also, if the answear is no, how would I then go around having only the text and NO background-color or image?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum