Installing gd library in PHP

Written by Deep

Some of the free web hosting providers gives limited features to their hosting. They may prevent default assigning such features like graphic drivers (gd) in PHP. You can manually enable this feature by requesting hosting provider or installing libraries at your end. Here is the solution for adding gd library to your PHP project.

You need to have pre-installed composer on your system.

Open root directory of your project.

In composer.json add following dependencies:

Save it and Update composer with following command in terminal (linux/ubuntu/mac) or cmd prompt (in windows):

Now gd library is enabled for your PHP project. You can use functions like imagecreatefromjpeg,  imagecreatetruecolor, imagecolorallocate, imagecopy etc.

Leave a Comment