我使用以下代码在 png 图像上使用 imagettftext() 函数。
但这似乎不起作用。
有什么解决办法吗?
ttf字体在index.php文件的当前目录下
<?php
require ("sdk/src/facebook.php");
$facebook=new Facebook(array('appId'=>'144694832322411','secret'=>'56456456456e6f75a5c4657befa','fileUpload'=>true,));
$user = $facebook->getUser();
if($user){
echo "User";
$im = imagecreate(200,200);
$rt='font.ttf';
$col = imagecolorallocate($im,255,0,0);
$v= imagecolorallocate($im,255,0,0);
try{
imagettftext($im,30.0,0.0,0,0,$v,$rt,"Hello");} catch (Exception $e){print_r($e);}
imagepng($im,'img.png');
echo "<img src='img.png'></img>";
} else {
$auth= "https://www.facebook.com/dialog/oauth/?client_id=144694832322411&redirect_uri=".urlencode("https://apps.facebook.com/lucky_elements")."&scope=user_about_me";
echo "<script>top.location.href=\"$auth\"</script>";
}
?>