当前位置:Gxlcms > PHP教程 > php中用GD库的imagettftext()函数生成图片失败怎么办?

php中用GD库的imagettftext()函数生成图片失败怎么办?

时间:2021-07-01 10:21:17 帮助过:1人阅读

我想根据输入的文字,生成特定字体的图片,根据php.com上的样例,并不能生成正确的图片,请问该怎么办?

样例中的图片:

我的图片:

代码:


我用的lnmp一键包搭的环境,编译里有--with-free-type-dir,

'./configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir=/usr/local/freetype' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-intl' '--with-xsl'

另外也支持free type:


更新:
在我改成用simhei.ttf(黑体 常规)字体后就可以正常显示了,为什么呢。。。

回复内容:

我想根据输入的文字,生成特定字体的图片,根据php.com上的样例,并不能生成正确的图片,请问该怎么办?

样例中的图片:

我的图片:

代码:


我用的lnmp一键包搭的环境,编译里有--with-free-type-dir,

'./configure' '--prefix=/usr/local/php' '--with-config-file-path=/usr/local/php/etc' '--enable-fpm' '--with-fpm-user=www' '--with-fpm-group=www' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' '--with-iconv-dir' '--with-freetype-dir=/usr/local/freetype' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--enable-mbregex' '--enable-mbstring' '--with-mcrypt' '--enable-ftp' '--with-gd' '--enable-gd-native-ttf' '--with-openssl' '--with-mhash' '--enable-pcntl' '--enable-sockets' '--with-xmlrpc' '--enable-zip' '--enable-soap' '--with-gettext' '--disable-fileinfo' '--enable-intl' '--with-xsl'

另外也支持free type:


更新:
在我改成用simhei.ttf(黑体 常规)字体后就可以正常显示了,为什么呢。。。

imagettftext支持TrueType类型的字体,imagepstext支持 PostScript Type1 字体。所以需要找到对应的字体,才会生效。

人气教程排行