abalonia
asked on
Freetype support in PHP
My web server used to support GD and Freetype with PHP. Now, after an upgrade, scripts that use GD still work, but not scripts that use freetype functions like imageFTText(). When I reinstalled PHP, I didn't compile it with freetype support. I reinstalled with these configure option:
./configure --with-apxs2=/usr/local/ap ache2/bin/ apxs --with-mysql --with-oci8=/home/oracle/p roduct/9.2 .0 --with-jpeg-dir=/usr --with-png-dir=/usr --with-gd --with-zlib --with-oracle=/home/oracle /product/9 .2.0 --with-zlib --with-ttf=/usr --with-freetype-dir=/usr
Then I ran "make" and "make install" and restarted Apache. I didn't get any error messages, but when I tried to run the PHP script that calls imageFTText(), I got the same error. I've also tried configuring without "--with-ttf", without "--with-freetype-dir", and using "/usr/lib" instead of "/usr", but with the same results. phpinfo() shows that the PHP installation is being updated.
The server runs Apache 2.2, PHP 5.1.2 on Red Hat Enterprise Linux 4 AS. gd-2.0.28-4.4E.1, gd-devel-2.0.28-4.4E.1, freetype-2.1.9-1, freetype-devel-2.1.9-1, and freetype-utils-2.1.9-1 are installed from the default Red Hat RPMs. /usr/lib contains:
-rw-r--r-- 1 root root 491356 Aug 4 2004 /usr/lib/libfreetype.a
-rwxr-xr-x 1 root root 816 Aug 4 2004 /usr/lib/libfreetype.la
lrwxrwxrwx 1 root root 20 Jun 6 17:41 /usr/lib/libfreetype.so -> libfreetype.so.6.3.7
lrwxrwxrwx 1 root root 20 Apr 5 16:02 /usr/lib/libfreetype.so.6 -> libfreetype.so.6.3.7
-rwxr-xr-x 1 root root 424068 Aug 4 2004 /usr/lib/libfreetype.so.6. 3.7
-rw-r--r-- 1 root root 255212 Jan 20 04:48 /usr/lib/libgd.a
-rwxr-xr-x 1 root root 229904 Jan 20 04:48 /usr/lib/libgd.so.2.0.0
Please help!
./configure --with-apxs2=/usr/local/ap
Then I ran "make" and "make install" and restarted Apache. I didn't get any error messages, but when I tried to run the PHP script that calls imageFTText(), I got the same error. I've also tried configuring without "--with-ttf", without "--with-freetype-dir", and using "/usr/lib" instead of "/usr", but with the same results. phpinfo() shows that the PHP installation is being updated.
The server runs Apache 2.2, PHP 5.1.2 on Red Hat Enterprise Linux 4 AS. gd-2.0.28-4.4E.1, gd-devel-2.0.28-4.4E.1, freetype-2.1.9-1, freetype-devel-2.1.9-1, and freetype-utils-2.1.9-1 are installed from the default Red Hat RPMs. /usr/lib contains:
-rw-r--r-- 1 root root 491356 Aug 4 2004 /usr/lib/libfreetype.a
-rwxr-xr-x 1 root root 816 Aug 4 2004 /usr/lib/libfreetype.la
lrwxrwxrwx 1 root root 20 Jun 6 17:41 /usr/lib/libfreetype.so -> libfreetype.so.6.3.7
lrwxrwxrwx 1 root root 20 Apr 5 16:02 /usr/lib/libfreetype.so.6 -> libfreetype.so.6.3.7
-rwxr-xr-x 1 root root 424068 Aug 4 2004 /usr/lib/libfreetype.so.6.
-rw-r--r-- 1 root root 255212 Jan 20 04:48 /usr/lib/libgd.a
-rwxr-xr-x 1 root root 229904 Jan 20 04:48 /usr/lib/libgd.so.2.0.0
Please help!
ASKER
I actually have GD 2.0.28 installed. I just tried downloading and installing GD 2.0.33 from source into /usr/local/lib. I can't uninstall the GD 2.0.28 rpm because too many other applications depend on it, plus I don't want to mess up Redhat's RPM update. I backed up the old GD libraries and include files, then copied the new libraries and include files from /usr/local/lib and /usr/local/include to /usr/lib and /usr/include. I recompiled PHP with and with "--with-freetype-dir=/usr" and both with and without "--with-ttf=/usr" and "--enable-gd-native-ttf", but imageFTText() still doesn't work. phpinfo displays the following for gd:
GD Support enabled
GD Version bundled (2.0.28 compatible)
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled
I guess it doesn't know that GD was upgraded? gdinfo() doesn't work for me.
GD Support enabled
GD Version bundled (2.0.28 compatible)
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled
I guess it doesn't know that GD was upgraded? gdinfo() doesn't work for me.
Hmmm.
How about putting the new libraries somewhere else and then using that location to the recompile?
Oops.
gd_info()
not
gdinfo()
Typo. Sorry.
From the PHP Manual ...
Returns an associative array describing the version and capabilities of the installed GD library.
Table 118. Elements of array returned by gd_info()
Attribute Meaning
GD Version string value describing the installed libgd version.
Freetype Support boolean value. TRUE if Freetype Support is installed.
Freetype Linkage string value describing the way in which Freetype was linked. Expected values are: 'with freetype', 'with TTF library', and 'with unknown library'. This element will only be defined if Freetype Support evaluated to TRUE.
T1Lib Support boolean value. TRUE if T1Lib support is included.
GIF Read Support boolean value. TRUE if support for reading GIF images is included.
GIF Create Support boolean value. TRUE if support for creating GIF images is included.
JPG Support boolean value. TRUE if JPG support is included.
PNG Support boolean value. TRUE if PNG support is included.
WBMP Support boolean value. TRUE if WBMP support is included.
XBM Support boolean value. TRUE if XBM support is included.
How about putting the new libraries somewhere else and then using that location to the recompile?
Oops.
gd_info()
not
gdinfo()
Typo. Sorry.
From the PHP Manual ...
Returns an associative array describing the version and capabilities of the installed GD library.
Table 118. Elements of array returned by gd_info()
Attribute Meaning
GD Version string value describing the installed libgd version.
Freetype Support boolean value. TRUE if Freetype Support is installed.
Freetype Linkage string value describing the way in which Freetype was linked. Expected values are: 'with freetype', 'with TTF library', and 'with unknown library'. This element will only be defined if Freetype Support evaluated to TRUE.
T1Lib Support boolean value. TRUE if T1Lib support is included.
GIF Read Support boolean value. TRUE if support for reading GIF images is included.
GIF Create Support boolean value. TRUE if support for creating GIF images is included.
JPG Support boolean value. TRUE if JPG support is included.
PNG Support boolean value. TRUE if PNG support is included.
WBMP Support boolean value. TRUE if WBMP support is included.
XBM Support boolean value. TRUE if XBM support is included.
I'm on Windows, so I'm pretty much stuck now.
ASKER
I got gd_info() working, and it doesn't show freetype support. I did try compiling PHP with the new GD libraries in /usr/local, but got a bunch of errors.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got GD and Freetype working after I recompiled PHP with the new version of the GD libraries that I installed in /usr/local, which is a different directory tree. The previous attempt failed because I didn't do a "make clean" before compiling.
Ah. The whole "having to recompile program to run" on Linux is probably (for a Windows user) one of the major issues I have.
I just download and install. Edit an INI file and restart webserver. Done!
BUT, I am always behind the releases (unless I use the snapshots).
Swings and roundabouts.
I just download and install. Edit an INI file and restart webserver. Done!
BUT, I am always behind the releases (unless I use the snapshots).
Swings and roundabouts.
From the PHP Manual (which seems to match what you are doing) ...
Enhance the capabilities of GD to deal with different fonts by specifying the --with-XXXX configure switch to your PHP configure line.
FreeType 1.x To enable support for FreeType 1.x add --with-ttf[=DIR].
FreeType 2 To enable support for FreeType 2 add --with-freetype-dir=DIR.
T1lib To enable support for T1lib (Type 1 fonts) add --with-t1lib[=DIR].
Native TrueType string function To enable support for native TrueType string function add --enable-gd-native-ttf.
Can you create a script gdinfo.php
<?php print_r(gdinfo()); ?>
I'm on windows and I get ...
array (
'GD Version' => 'bundled (2.0.28 compatible)',
'FreeType Support' => true,
'FreeType Linkage' => 'with freetype',
'T1Lib Support' => true,
'GIF Read Support' => true,
'GIF Create Support' => true,
'JPG Support' => true,
'PNG Support' => true,
'WBMP Support' => true,
'XPM Support' => false,
'XBM Support' => true,
'JIS-mapped Japanese Font Support' => false,
)
Which is also reflected in phpinfo().
If you get similar output to me, it suggests that everything is OK with PHP.
My php.ini only has ext=php_gd2.dll activated.
So - what is the version of GD you are getting back?
From the PHP Manual for imagefttext() ...
Note:
This function requires GD 2.0.1 or later (2.0.28 or later is recommended).
You say you have /usr/lib/libgd.so.2.0.0. I'm not a *ix bod, but I suspect that this is the issue.
You need 2.0.1 at least.