/*create watermark*/
// Create the image
$im = imagecreate(460, 50);
// Create some colors
$grey = imagecolorallocate($im, 230, 231, 232);
$dark_grey = imagecolorallocate($im, 128, 130, 133);
// The text to draw
$text = "foobar";
// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));
$font = 'Tondu_beta';
// Add the text
imagettftext($im, 15, 0, 15, 35, $dark_grey, $font, $text);
$wm_w = imagesx($im); //get width
$wm_h = imagesy($im); //get height
$wmresource = $im; //watermark resource
//imagejpeg($wmresource);
/*end watermark*/
字体文件是Tondu_Beta.ttf。上面的代码在我的本地机器上工作得很好,但它只是在上传到活动服务器后给了我一个灰色框。这里有什么问题?谢谢^^imagettftext()不起作用
更新:我记得它给了我这个错误:Could not find/open font bla.bla..bla...
检查错误日志,看看。 – ceejayoz 2012-07-23 17:31:23
也许你的现场服务器没有字体?... – Palladium 2012-07-23 17:33:33
脚本是否知道要在该文件夹中查找字体? – Palladium 2012-07-23 17:35:13