Detect if the FreeType PHP extension is installed on the server

Bluemagica picture Bluemagica · Jan 4, 2011 · Viewed 15.7k times · Source

How do I test to see if the FreeType extension is installed on a server running PHP?

I wanted to make a simple CAPTCHA system on my site, so I used imagettftext() and it worked fine. But what if the server didn't have the FreeType library installed?

So is there a way to somehow detect FreeType library through code, and if it is not present, fall back to something like imagestring()?

If I can't use imagettftext() I may have to look at alternatives to draw big font text as the imagestring max size isn't good for something like a CAPTCHA.

Answer

Jon picture Jon · Jan 4, 2011

This will not be better in practice than the function_exists solutions already posted, but the technically correct way to check is by using extension_loaded.