PHP生成透明图层的代码
原创 52cxy 03-27 14:08 阅读数:818

下面代码可生成透明图层:

$width = 400;
$height = 400;
$layer = imagecreatetruecolor($width, $height);
 
//设置透明背景
imagesavealpha($layer, true);
$transparentColor = imagecolorallocatealpha($layer, 0, 0, 0, 127);
imagefill($layer, 0, 0, $transparentColor);
 
//添加文字
$textColor = imagecolorallocate($layer, 255, 255, 255);
$fontFile = './arial.ttf';
$text = 'Hello, World!';
$fontSize = 12;//字号
$angle = 0; //旋转角度
$x = 50;
$y = 100;
imagettftext($layer, $fontSize, $angle, 10, 50, $textColor, $fontFile, $text);
 
header('Content-Type: image/png');
imagepng($layer); 
imagedestroy($layer);


共0条评论
我要评论