PHP/GD2: undefined function imagettftext()

Posted on 2007-10-15
Last Modified: 2012-05-05

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;
Question by:hankknight
    LVL 1

    Accepted Solution

    imagettftext() requires the Freetype lib. Check that you have this installed as well.
    LVL 48

    Assisted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Suggested Solutions

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now