software development


I am having problems with making dynamic text with the imagettftext() function in PHP. I have uploaded the script to other servers and it seems to work fine, and yes I made sure I uploaded a copy of the font. The image comes up fine, just no text :(. Here is the script

header(“Content-type: image/png”);
$string = $_GET[‘text’];
$font = “…/font/verdana.ttf”;
$im = imagecreatefrompng("…/images/lgbutton.png");
$gray = imagecolorallocate($im, 167, 167, 167);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagettftext($im, 10, 0, $px, 23, $gray, $font, $string);

Any thought/feelings/ideas would be appreciated



I don’t think using such commands for Verdana is necessary. 99% of PC’s have the font installed with the OS.


It is required when the webserver is running linux or windows, otherwise PHP does not have a clue what font to render it to when rendering a TTF font to an image using PHP. I could substitute it with an obscure font and I will still not work. My own webservers will handle it and render it without issue (not hosted by dreamhost and built by me) but dreamhost’s php does not seem to be compiled preperly or something


I remember posting about this problem in the past, so I did a search for “imagettftext” and came up with the following:

My suspicion was that it’s a configuration problem. If that theory is correct, it would require an email to support suggesting that they recompile PHP with the correct option.


I already tried the imagefttext() function and it is still broken :(, I will contact support. Thanks