Forum Moderators: coopster
According to PHP manual this should be the function used to combine images while maintaining the alpha.
Here is code (new to GD, so this may be all wrong):
<?php
$txt = $_GET['text'];
header("Content-type: image/png");
$image = imagecreatetruecolor(110, 30);
$transparentColor = imagecolorallocatealpha($image, 200, 200, 200, 127);
imagefill($image, 0, 0, $transparentColor);
imageSaveAlpha($image, true);
ImageAlphaBlending($image, false);
$bgimage = imagecreatefrompng("button_grad.png");
imageSaveAlpha($bgimage, true);
imageAlphaBlending($bgimage, false);
imagecopymerge($image,$bgimage,0,0,0,0,110,30,0);
$text_color = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 1, 5, 5, $txt, $text_color);
imagepng($bgimage);
imagedestroy($image);
imagedestroy($bgimage);
?>
***All I get is a grey image.
Misunderstood this line in the imagecopymerge:
The two images will be merged according to pct which can range from 0 to 100. When pct = 0, no action is taken, when 100 this function behaves identically to imagecopy() for pallete images, while it implements alpha transparency for true colour images.