微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PHP – imagettftext无法正常工作并安装了GD

这是长时间,我仍然在寻找这个问题的答案..
我找到的所有解决方案都围绕着字体名称,但我很确定这不是我的问题.

它看起来像是安装了GD

array(11) {
  ["GD Version"]=>
  string(27) "bundled (**2.0.34 compatible**)"
  ["FreeType Support"]=>
  bool(false)
  ["T1Lib Support"]=>
  bool(false)
  ["GIF Read Support"]=>
  bool(true)
  ["GIF Create Support"]=>
  bool(true)
  ["JPEG Support"]=>
  bool(true)
  ["PNG Support"]=>
  bool(true)
  ["WBMP Support"]=>
  bool(true)
  ["XPM Support"]=>
  bool(true)
  ["XBM Support"]=>
  bool(true)
  ["JIS-mapped Japanese Font Support"]=>
  bool(false)
}

上面你可以看到我的GD支持.
我的PHP版本是5.3,我在Linux上运行.

我尝试过来自不同网站的几个不同的代码示例,但都没有.
ImageString确实适合我,但我需要让imagettftext工作..

这是我现在尝试的最后一个代码

<?PHP
ini_set('display_errors',1);
error_reporting(E_ALL);

// Set the content-type
header('Content-Type: image/png');

// Create the image
$im = imagecreatetruecolor(400,100) or die("Can't create image!");

// Create some colors
$white = imagecolorallocate($im,255,255);
$grey = imagecolorallocate($im,128,128);
$black = imagecolorallocate($im,0);
imagefilledrectangle($im,399,29,$white);

// The text to draw
$text = 'Testing';
// Replace path by your own font path
$font = 'arial.ttf';

// Add some shadow to the text
imagettftext($im,20,11,21,$grey,'arial.ttf',$text);

// Add the text
imagettftext($im,10,$black,$text);

// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>

结果:http://www.7679679.com/app/test-ansi.php

有同样的问题,安装了FreeType,解决方案是
$font = "./Arial.ttf"; // <--- put ./ in front of filename

原文地址:https://www.jb51.cc/php/133621.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐