0
我需要使用imagepng中的图像中的文本& imagettftext函数在PHP中。PHP imagettftext center text
这里是我的代码:
include "config.php";
header('Content-type: image/png');
function between($src,$start,$end){
$txt=explode($start,$src);
$txt2=explode($end,$txt[1]);
return trim($txt2[0]);
}
$actual = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$background1 = "files/bg.png";
$background = imagecreatefrompng($background1);
//FONTS
$tahoma = "files/tahoma.ttf";
$bebas = "files/BebasNeue.otf";
$italic = "files/TahomaItalic.ttf";
$bold = "files/TahomaBold.ttf";a
//COLORS
$gray = imagecolorallocate($background, 76, 76, 76);
$dark_shadow = imagecolorallocate($background, 169, 181, 188);
//NAME
imagettftext($background, 32, 0, 181, 173, $gray, $bebas, urldecode(between($actual, "name=", "|")));
imagepng($background);
imagedestroy($background);
的文本是URL参数 “名”。 我需要将此文本居中放置在图像中。 ?
imagettftext($background, 32, 0, 181, 173, $gray, $bebas, urldecode(between($actual, "name=", "|")));
________________________________________
| |
| |
| MY TEXT |
| |
| |
| |
| |
| |
---------------------------------------
你到底在问什么? – 2014-10-17 12:17:23
@RobertVerkerk我需要在imagepng中使用imagettftext将文本居中。我的意思是我的文本是一个水印,我需要使用php imagepng将它置于图像中。 – 2014-10-17 12:19:31