20

First of all, I am sorry if my question may be too vague. So, I will try to clarify my question as much as possible.

I am currently developing a Laravel application, and I am trying to use Intervention Image Facade. When I tried to use it to test an upload, I got the following error:-

NotSupportedException in Driver.php line 16: GD Library extension not available with this PHP installation.

So, as I would try to do, I installed the GD library using sudo apt-get install libgd3 and the php gd driver using sudo apt-get php5.6-gd. However, this did not work, and the same error keeps popping up in laravel. What have I clearly missed, and what should I follow next?

Edit 1. I used the following command to see if php actually supports gd driver : - php -i | grep -i --color gd

The following result came: -

/etc/php/5.6/cli/conf.d/20-gd.ini,
gd
GD Support => enabled
GD headers Version => 2.2.3
GD library Version => 2.2.3
gd.jpeg_ignore_warning => 0 => 0
GDM_LANG => en_US
GDMSESSION => ubuntu
_SERVER["GDM_LANG"] => en_US
_SERVER["GDMSESSION"] => ubuntu

Hope this helps even more.

EDIT 2 Thanks to all who answered. I found my solution in Mayank Pandey's answer.

7 Answers7

32

This is because the GD Library is missing on your server For PHP 8.x

Find your (proper) php.ini file, and then find the line:enter image description here

;extension=gd, remove the semicolon in the front. ; means the line is commented, so remove the comment.

The line should look like this:

extension=gd

Then restart apache and you are ready to go.

NOTE: If You are using php version <=7.x

;extension=php_gd2.dll, itshould look like this: extension=php_gd2.dll

Haron
  • 2,371
  • 20
  • 27
23

This is because the GD Library is missing on your server.

You must enable the library GD2.

Find your (proper) php.ini file, and then find the line:

;extension=php_gd2.dll, remove the semicolon in the front. ; means the line is commented, so remove the comment)

The line should look like this:

extension=php_gd2.dll

Then restart apache and you are ready to go.

Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
8

If using php 8

  1. go to xampp/php/php.ini and find ;extension=gd as shown in image

  2. replace ;extension=gd with extension=gd (just remove the ; and save)

enter image description here

  1. finally restart apache.. thats all
Nazmul Hoque
  • 761
  • 9
  • 9
7

Install GD extension:

sudo apt-get install php7.0-gd

For PHP 7.1 try the following:

sudo apt-get install php7.1-gd

For PHP 7.2 try the following:

sudo apt-get install php7.2-gd

Then restart your server.

Apache:

sudo service apache2 restart

Nginx:

sudo service nginx restart
Ostap Brehin
  • 3,240
  • 3
  • 25
  • 28
  • I hope you had read the question, as I followed the above steps. I needed help afterward. But thank you for answering. – Kavinda Keshan Rasnayake Oct 23 '17 at 05:25
  • Restarting apache didn't work. I had to reboot the server for it to work. – andromeda Apr 23 '19 at 06:29
  • 1
    Restarting apache didn't work because I was serving my laravel app using php artisan serve which uses a different .ini file. So you need to stop php artisan serve and start it again for changes to reflect. – andromeda Apr 23 '19 at 09:07
1

As @nafischonchol said, you should also stop and start php artisan serve on local after enabling gd extension on php.ini file and stop and start apache.

Hesam Moosapour
  • 510
  • 5
  • 12
0

Did you enable the gd extension?

try this is your termital

php -i | grep gd

my output is:

frank@frank-ThinkPad-T430:~$ php -i | grep gd
/etc/php/7.0/cli/conf.d/20-gd.ini,
gd
gd.jpeg_ignore_warning => 0 => 0
VVN
  • 1,607
  • 2
  • 16
  • 25
Frank LAN
  • 3
  • 2
0

After all the above failed, I upgraded to php 7.3.x from php7.2.x, using

    sudo apt install php

then installed gd

    sudo apt-get install php7.3-gd

to be sure, restart the apache server or xampp(as was for my case) and also restart php artisan serve.

Using the appropriate php.ini file, ensure that "extension=php_gd2.dll" is enabled by removing the semicolon that appears before it.

then check what you have on grep through

    php -i | grep -i --color gd

it should look like this.

/etc/php/7.3/cli/conf.d/20-gd.ini,
gd
GD Support => enabled
GD headers Version => 2.2.5
GD library Version => 2.2.5
gd.jpeg_ignore_warning => 1 => 1
GDM_LANG => C.UTF-8
GDMSESSION => gnome
XAUTHORITY => /run/user/1000/gdm/Xauthority
$_SERVER['GDM_LANG'] => C.UTF-8
$_SERVER['GDMSESSION'] => gnome
$_SERVER['XAUTHORITY'] => /run/user/1000/gdm/Xauthority

in the case that after this, you get an error concerning drivers on your laravel app, this answer may help solve it.Laravel 5 PDOException Could Not Find Driver

I hope this helps you.

Doreen Chemweno
  • 303
  • 2
  • 6