PHP/GD2: undefined function imagettftext()


I have a PHP script that works perfectly on one server but causes a fatal error on another:

        Fatal error: Call to undefined function imagettftext() on line 8

Both have GD2 installed.  I use PHP 5.2.4.  Any ideas why this is not working?  Here is my script:


print_r (better_imagettfbbox ('12', '44', 'arial.ttf', 'Hello World'));

function better_imagettfbbox($size, $angle, $font, $text) {
  $dummy = imagecreate(1, 1);
  $black = imagecolorallocate($dummy, 0, 0, 0);
  $bbox = imagettftext($dummy, $size, $angle, 0, 0, $black, $font, $text);
  return $bbox;
LVL 16
Who is Participating?
ahincConnect With a Mentor Commented:
imagettftext() requires the Freetype lib. Check that you have this installed as well.
hernst42Connect With a Mentor Commented:
on a unix server the gd must be compiled with the option --enable-gd-native-ttf Check your phpinfo() for compile options. On windows the function is mormaly available if gs is loaded.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.