PHP and GD Library

PHP, Apache and GD Library

PHP has quite an array of built-in functions which can be used to create, delete and manipulate images. Many image functions which need the GD library, such as getimagesize(), imagecreate(), imagedestroy(), imagetypes(), imagecreatetruecolor(), imagejpg() and getimagesize() can be found here:

However, in order to use these functions without generating errors, you need the GD library installed. It is likely to be available on shared hosting accounts, but, you may need to install and enable the module with a VPS or dedicated server.

Is the GD Library Installed?

If you attempt to use a function that is not part of the core PHP(like GD library) nd you have not loaded the

module for it, you will get an error like:

    Fatal error: Call to undefined function: imagecreate()

Adding the GD Library

Web Host Manager is a very popular Linux application that runs on CENTOS servers. One simple method to have GD library up and running is to follow the instructions given below.

1) Login to WHM(Web Host Manager)
2) Select Software -> EasyApache
3) Near step 5, click Exhaustive Options List which shows many more options
4) Scroll down under PHP and check GD >Build with new features