如何正确配置PHP的GD支持?调用imagettfbbox()时收到错误

时间:2022-10-16 13:37:05

Using Symfony2.0 and Gregwar Captcha Bundle for Symfony 2.0 Operating System: Mac OS 10.10 (Yosemite)

使用Symfony2.0和Gregwar Captcha Bundle for Symfony 2.0操作系统:Mac OS 10.10(Yosemite)

After having installed the CaptchaBundle following the instructions, the first time I use it, I get the following error:

按照说明安装CaptchaBundle后,第一次使用它时,我收到以下错误:

Fatal error: Call to undefined function Gregwar\CaptchaBundle\Generator\imagettfbbox() in /Users/pgbonino/Sites/preparatest/vendor/bundles/Gregwar/CaptchaBundle/Generator/CaptchaGenerator.php on line 176

致命错误:在第176行的/Users/pgbonino/Sites/preparatest/vendor/bundles/Gregwar/CaptchaBundle/Generator/CaptchaGenerator.php中调用未定义函数Gregwar \ CaptchaBundle \ Generator \ imagettfbbox()

My phpinfo informs this:

我的phpinfo告诉我:

<h2><a name="module_gd">gd</a></h2>
<table border="0" cellpadding="3" width="600">
<tbody><tr><td class="e">GD Support </td><td class="v">enabled </td></tr>
<tr><td class="e">GD Version </td><td class="v">bundled (2.1.0 compatible) </td></tr>
<tr><td class="e">GIF Read Support </td><td class="v">enabled </td></tr>
<tr><td class="e">GIF Create Support </td><td class="v">enabled </td></tr>
<tr><td class="e">JPEG Support </td><td class="v">enabled </td></tr>
<tr><td class="e">libJPEG Version </td><td class="v">9 compatible </td></tr>
<tr><td class="e">WBMP Support </td><td class="v">enabled </td></tr>
<tr><td class="e">XBM Support </td><td class="v">enabled </td></tr>
</tbody></table>

So, apparently the GD module is correctly loaded.

所以,显然GD模块已正确加载。

Any idea on the error I am getting?

对我得到的错误有任何想法吗?

1 个解决方案

#1


2  

Comparing your phpinfo() output to mine I find that although GD is active FreeType is missing in your PHP installation. The PHP docs on imagettfbbox() say that "This function requires both the GD library and the FreeType library."

比较你的phpinfo()输出我发现虽然GD是活动的,但PHP安装中缺少FreeType。 imagettfbbox()上的PHP文档说“这个函数需要GD库和FreeType库”。

Here is the corresponding section of my phpinfo():

这是我的phpinfo()的相应部分:

gd

GD Support  enabled
GD Version  bundled (2.1.0 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.5.3
GIF Read Support    enabled
GIF Create Support  enabled
JPEG Support    enabled
libJPEG Version 8
PNG Support enabled
libPNG Version  1.6.13
WBMP Support    enabled
XBM Support enabled

The Configure Command block at the beginning of phpinfo should list freetype too:

phpinfo开头的Configure Command块也应列出freetype:

'./configure' '--prefix=/usr/local/Cellar/php55/5.5.18' '--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/5.5' '--with-config-file-path=/usr/local/etc/php/5.5' '--with-config-file-scan-dir=/usr/local/etc/php/5.5/conf.d' '--with-iconv-dir=/usr' '--enable-dba' '--with-ndbm=/usr' '--enable-exif' '--enable-intl' '--enable-soap' '--enable-wddx' '--enable-ftp' '--enable-sockets' '--enable-zip' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-mbstring' '--enable-mbregex' '--enable-bcmath' '--enable-calendar' '--with-zlib=/usr/local/opt/zlib' '--with-ldap' '--with-ldap-sasl=/usr' '--with-xmlrpc' '--with-kerberos=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/local/opt/freetype' '--with-icu-dir=/usr/local/opt/icu4c' '--with-jpeg-dir=/usr/local/opt/jpeg' '--with-png-dir=/usr/local/opt/libpng' '--with-gettext=/usr/local/opt/gettext' '--with-libedit' '--with-unixODBC=/usr/local/opt/unixodbc' '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' '--mandir=/usr/local/Cellar/php55/5.5.18/share/man' '--with-mhash' '--with-curl' '--with-snmp=/usr' '--with-bz2=/usr' '--disable-debug' '--with-openssl=/usr' '--with-xsl=/usr' '--with-apxs2=/usr/sbin/apxs' '--libexecdir=/usr/local/Cellar/php55/5.5.18/libexec' '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd' '--with-mysql=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-pcntl' '--enable-zend-signals' '--enable-dtrace' '--enable-opcache'

'./configure'' - prefix = / usr / local / Cellar / php55 / 5.5.18'' - localstatedir = / usr / local / var'' - sysddir = / usr / local / etc / php / 5.5 '' - with-config-file-path = / usr / local / etc / php / 5.5'' - with-config-file-scan-dir = / usr / local / etc / php / 5.5 / conf.d '' - with-iconv-dir = / usr'' - enable-dba'' - with-ndbm = / usr'' - enable-exif'' - enable-intl'' - enable-soap ''--able-wddx'' - enable-ftp'' - enable-sockets'' - enable-zip'' - enable-shmop'' - enable-sysvsem'' - enable-sysvshm' '--enable-sysvmsg'' - enable-mbstring'' - enable-mbregex'' - enable-bcmath'' - enable-calendar'' - with-zlib = / usr / local / opt / zlib '' - with-ldap'' - with-ldap-sasl = / usr'' - with-xmlrpc'' - with-kerberos = / usr'' - with-gd'' - enable-gd -native-ttf'' - with-freetype-dir = / usr / local / opt / freetype'' - with-icu-dir = / usr / local / opt / icu4c'' - with-jpeg-dir = / usr / local / opt / jpeg'' - with-png-dir = / usr / local / opt / libpng'' - with-gettext = / usr / local / opt / gettext'' - with-libedit' '--with-unixODBC = / usr / local / opt / unixodbc'' - with-pdo-odbc = unixODBC,/ usr / loc al / opt / unixodbc'' - mandir = / usr / local / Cellar / php55 / 5.5.18 / share / man'' - with-mhash'' - with-curl'' - with-snmp = / usr'' - with-bz2 = / usr'' - disable-debug'' - with-openssl = / usr'' - with-xsl = / usr'' - with-apxs2 = / usr / sbin / apxs'' - libdcdir = / usr / local / Cellar / php55 / 5.5.18 / libexec'' - with-mysql-sock = / tmp / mysql.sock'' - with-mysqli = mysqlnd'' - -with-mysql = mysqlnd'' - with-pdo-mysql = mysqlnd'' - enable-pcntl'' - enable-zend-signals'' - enable-dtrace'' - enable-opcache'

POSSIBLE SOLUTION

可能的解决方案

From your comment on my instructions to install a full PHP on OSX Yosemite I know that you have installed PHP using the Homebrew package manager. So you might want to try this to solve your problem:

从你对我的指示的评论来在OSX Yosemite上安装一个完整的PHP我知道你已经使用Homebrew包管理器安装了PHP。所以你可能想尝试这个来解决你的问题:

brew install freetype

#1


2  

Comparing your phpinfo() output to mine I find that although GD is active FreeType is missing in your PHP installation. The PHP docs on imagettfbbox() say that "This function requires both the GD library and the FreeType library."

比较你的phpinfo()输出我发现虽然GD是活动的,但PHP安装中缺少FreeType。 imagettfbbox()上的PHP文档说“这个函数需要GD库和FreeType库”。

Here is the corresponding section of my phpinfo():

这是我的phpinfo()的相应部分:

gd

GD Support  enabled
GD Version  bundled (2.1.0 compatible)
FreeType Support    enabled
FreeType Linkage    with freetype
FreeType Version    2.5.3
GIF Read Support    enabled
GIF Create Support  enabled
JPEG Support    enabled
libJPEG Version 8
PNG Support enabled
libPNG Version  1.6.13
WBMP Support    enabled
XBM Support enabled

The Configure Command block at the beginning of phpinfo should list freetype too:

phpinfo开头的Configure Command块也应列出freetype:

'./configure' '--prefix=/usr/local/Cellar/php55/5.5.18' '--localstatedir=/usr/local/var' '--sysconfdir=/usr/local/etc/php/5.5' '--with-config-file-path=/usr/local/etc/php/5.5' '--with-config-file-scan-dir=/usr/local/etc/php/5.5/conf.d' '--with-iconv-dir=/usr' '--enable-dba' '--with-ndbm=/usr' '--enable-exif' '--enable-intl' '--enable-soap' '--enable-wddx' '--enable-ftp' '--enable-sockets' '--enable-zip' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-mbstring' '--enable-mbregex' '--enable-bcmath' '--enable-calendar' '--with-zlib=/usr/local/opt/zlib' '--with-ldap' '--with-ldap-sasl=/usr' '--with-xmlrpc' '--with-kerberos=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-freetype-dir=/usr/local/opt/freetype' '--with-icu-dir=/usr/local/opt/icu4c' '--with-jpeg-dir=/usr/local/opt/jpeg' '--with-png-dir=/usr/local/opt/libpng' '--with-gettext=/usr/local/opt/gettext' '--with-libedit' '--with-unixODBC=/usr/local/opt/unixodbc' '--with-pdo-odbc=unixODBC,/usr/local/opt/unixodbc' '--mandir=/usr/local/Cellar/php55/5.5.18/share/man' '--with-mhash' '--with-curl' '--with-snmp=/usr' '--with-bz2=/usr' '--disable-debug' '--with-openssl=/usr' '--with-xsl=/usr' '--with-apxs2=/usr/sbin/apxs' '--libexecdir=/usr/local/Cellar/php55/5.5.18/libexec' '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=mysqlnd' '--with-mysql=mysqlnd' '--with-pdo-mysql=mysqlnd' '--enable-pcntl' '--enable-zend-signals' '--enable-dtrace' '--enable-opcache'

'./configure'' - prefix = / usr / local / Cellar / php55 / 5.5.18'' - localstatedir = / usr / local / var'' - sysddir = / usr / local / etc / php / 5.5 '' - with-config-file-path = / usr / local / etc / php / 5.5'' - with-config-file-scan-dir = / usr / local / etc / php / 5.5 / conf.d '' - with-iconv-dir = / usr'' - enable-dba'' - with-ndbm = / usr'' - enable-exif'' - enable-intl'' - enable-soap ''--able-wddx'' - enable-ftp'' - enable-sockets'' - enable-zip'' - enable-shmop'' - enable-sysvsem'' - enable-sysvshm' '--enable-sysvmsg'' - enable-mbstring'' - enable-mbregex'' - enable-bcmath'' - enable-calendar'' - with-zlib = / usr / local / opt / zlib '' - with-ldap'' - with-ldap-sasl = / usr'' - with-xmlrpc'' - with-kerberos = / usr'' - with-gd'' - enable-gd -native-ttf'' - with-freetype-dir = / usr / local / opt / freetype'' - with-icu-dir = / usr / local / opt / icu4c'' - with-jpeg-dir = / usr / local / opt / jpeg'' - with-png-dir = / usr / local / opt / libpng'' - with-gettext = / usr / local / opt / gettext'' - with-libedit' '--with-unixODBC = / usr / local / opt / unixodbc'' - with-pdo-odbc = unixODBC,/ usr / loc al / opt / unixodbc'' - mandir = / usr / local / Cellar / php55 / 5.5.18 / share / man'' - with-mhash'' - with-curl'' - with-snmp = / usr'' - with-bz2 = / usr'' - disable-debug'' - with-openssl = / usr'' - with-xsl = / usr'' - with-apxs2 = / usr / sbin / apxs'' - libdcdir = / usr / local / Cellar / php55 / 5.5.18 / libexec'' - with-mysql-sock = / tmp / mysql.sock'' - with-mysqli = mysqlnd'' - -with-mysql = mysqlnd'' - with-pdo-mysql = mysqlnd'' - enable-pcntl'' - enable-zend-signals'' - enable-dtrace'' - enable-opcache'

POSSIBLE SOLUTION

可能的解决方案

From your comment on my instructions to install a full PHP on OSX Yosemite I know that you have installed PHP using the Homebrew package manager. So you might want to try this to solve your problem:

从你对我的指示的评论来在OSX Yosemite上安装一个完整的PHP我知道你已经使用Homebrew包管理器安装了PHP。所以你可能想尝试这个来解决你的问题:

brew install freetype