Home > Backend Development > PHP Tutorial > Call to undefined function imagettftext solution

Call to undefined function imagettftext solution

WBOY
Release: 2016-07-29 08:58:16
Original
2429 people have browsed it

Published by Lao Gao on 2014-10-03 In the Code Life category

When Lao Gao installed DEDECMS in a new environment, he found that the background verification code could not be displayed. Search for this error directly. Some people say that the session is wrong, some say that the permissions are wrong, etc. Isn’t this nonsense! You can only look at the source code and locate the file /include/vdimgck.php. The error function is imagettftext(). Because DreamWeaver used @ to hide the error, this inexplicable error occurred. Remove @, and the error will appear immediately:

Fatal error: Call to undefined function imagettftext()

Now we know clearly that the reason for the error is that FreeType was not added when PHP was compiled.

Solution:

First compile and install FreeType, taking 2.4.0 as an example:

<code><span>wget http://download.savannah.gnu.org/releases/freetype/freetype-<span>2.4.<span>0.tar.bz2
<span>tar -jxf freetype-<span>2.4.<span>0.tar.bz2
<span>cd reetype-<span>2.4.<span>0
<span># 安装到/usr/local/freetype
./configure --prefix=/usr/<span>local/freetype
<span>make && <span>make <span>install
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code>
Copy after login

Next we recompile PHP and add the parameters --with-freetype-dir=/usr/local/freetype

<code>./configure \
<span>... \
<span>... \
--<span>with-freetype-dir=/usr/local/freetype
</span></span></span></code>
Copy after login

After compiling, restart php

<code>kill -USR2 `<span>cat /usr/local/php/<span>var/run/php-fpm.pid`
</span></span></code>
Copy after login

and find FreeType Support in the GD library, indicating that the installation is successful!

It should be noted that if the server freetype version is 1.*, then you may need to change the compilation parameters to --with-ttf[=DIR], the following is reproduced from the ChinaUnix Forum:

Font configuration switch
FreeType 1.x To activate FreeType 1.x support, add --with-ttf[=DIR].
FreeType 2 To activate FreeType 2 support, add --with-freetype-dir=DIR.
T1lib To activate T1lib (Type 1 font), add --with-t1lib[=DIR].
Native TrueType string functions To activate support for native TrueType string functions, add --enable-gd-native-ttf.

Reference:

http://bbs.chinaunix.net/thread-610205-1-1.html

The above introduces the solution to Call to undefined function imagettftext, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template