Imagettftext not working on WAMP


I am creating an image with GD which contains text created with imagettftext()

As my code is working perfectly on my Mac it does not on a windows computer with WAMP.

I have already checked the config and all looks good:

I have also installed freetype.

I get no error or warning. In fact when I for example give a filename for the font which does not exist, I get an error on the Mac. On the windows computer I can put whatever I want in the fonts filename nothing happens. That means to me that it is not even coming that far on the computer.

Has anyone an idea what I should do next?


I just did a test here using the example script from and that works for me.
Wampserver 3.2.9 64bit, PHP 8.1.0 on Windows 10.

Before I copied the font to the folder I got an error in the browser, saying it could not display the image becaue it contains errors.
I had to comment out the PNG header to see the actual errors from Xdebug.
When I added the font, it was fine.

I have only PHP7.3.12 available on this computer

It’s Firefox which says it can’t display because of errors. In Chrome I just get a little square in the middle of the screen, same in Edge.
But as I say, removing the PNG header lets me see errors for Xdebug.

I’ll try in an earlier version.

It doesn’t work for me in any 7.# versions. But it’s fine in 8.#
If I comment the header it says it can’t find/open the font.

That’s strange because on my Mac with PHP 7.3.30 it works perfect

The error is about finding or opening the font. In the example script I’m testing the reference is simply:-

$font = 'arial.ttf';

So the font file is in the same folder as the script, which is where I copied it to.
Perhaps it is something to do with the file path. :confused:
This is what I see with the header removed.

This is with the header:-

It has nothing to do with the font.

I have just checked the same script which you used from PHP manual, on the windows machine and ion a server running centOS with PHP 7.4.24

For both there is no error or warning (even if I remove the content type like you did) but there is also no text. I tried to copy arial.ttf to the same directory too but no change.

This is the result on both machines:

I am really out of ideas what the issue is and how to fix it.


don’t ask me why but it has to do something with the fonts even if it does not throw an error at all.

On windows it is running if you use


and on centOS when you use


So there seems to be no way to handle both OS the same way but ok…

What browser? That’s similar to what I saw in Chrome and Edge, except it was just a square, not as wide as that. Only Firefox showed the image error message.

Sorry I can’t shed any light on this. It’s a bit of a mystery.
I guess this is what they mean when people talk about inconsistencies when running PHP on different OSs.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.