Php gd installed but not enabled

On the localhost the library is working fine, when the function is called on production,php throws a fatal errer.

i checked the phpinfo() its there and it is enabled.

I tired to see if there is anything that i can add on the php.ini but i couldn't find any. The error is thrown when i call

gd_info();

Is there anything that i can add on the php.ini file that can solve this problem, or is there another library for gd?

The error am getting is the following

Fatal error: Call to undefined function gd_info(

asked Jun 5, 2011 at 16:33

4

I had exactly the same problem

although I had installed it using apt-get install php7.0-gd that function was undefined, so I inspected php.ini file in /etc/php/7.0/apache2/php.ini

turned out that the line for gd extension was commented!

so I removed semicolon before the line and it was working!

so crazy wasted an half an hour of mine :D

answered Nov 18, 2016 at 17:51

Php gd installed but not enabled

DeveloperiumDeveloperium

7,0455 gold badges33 silver badges54 bronze badges

It may be a little bit late, but I hope it helps anyone.

I had the same problem when I tried to run GD over apache. The problem was in php.ini path for apache. By default it is not using php.ini from php directory. You need to define PHPIniDir in httpd file or place copy of php.ini to apache folder.

To check if it is your case you can compare output of php --ini from php folder and output of phpinfo() over apache. If it is showing different php.ini destinations you need to fix it.

answered Jun 9 at 19:42

EgorEgor

1,1826 silver badges21 bronze badges

Logged in as root, I installed the php-gd libraries using

$ yum install php-gd

it said everything worked fine, so i did

$ /etc/init.d/nginx restart

But the code I had been working on still complained of not having the gd libraries and when I went to check the output of phpinfo there was no 'gd' section.

I should note that yum list | grep gd shows

gd.i386  2.0.33-9.4.el5_1.1  installed
gd-devel.i386  2.0.33-9.4.el5_1.1  installed
gdb.i386  6.8-27.el5  installed
gdbm.i386  1.8.0-26.2.1  installed
php-gd.i386  5.1.6-23.2.el5_3  installed

I also added extension=gd.so manually to /etc/php.ini and it is still not showing up or raising an error which leads me to believe my php.ini is not being re-parsed when I restart nginx. Is there something outside of restarting nginx I have to do to get php.ini changes loaded?

I have a fair amount (like 3 years) of ad-hoc server administration experience although no formal training, but I'm relatively new to nginx and have never worked with CentOS before, so any help would be much appreciated.

To enable GD-support configure PHP --with-gd[=DIR], where DIR is the GD base install directory. To use the recommended bundled version of the GD library, use the configure option --with-gd. GD library requires libpng and libjpeg to compile. As of PHP 7.4.0, --with-gd becomes --enable-gd (whether to enable the extension at all) and --with-external-gd (to opt into using an external libgd, rather than the bundled one).

In Windows, you'll include the GD DLL php_gd.dll as an extension in php.ini. Prior to PHP 8.0.0, the DLL was named php_gd2.dll.

Enhance the capabilities of GD to handle more image formats by specifying the --with-XXXX configure switch to your PHP configure line.

Supported image formats
Image FormatConfigure Switch
jpeg To enable support for jpeg add --with-jpeg-dir=DIR. Jpeg 6b, 7 or 8 are supported. As of PHP 7.4.0, use --with-jpeg instead.
png To enable support for png add --with-png-dir=DIR. Note, libpng requires the zlib library, therefore add --with-zlib-dir[=DIR] to your configure line. As of PHP 7.4.0, --with-png-dir and --with-zlib-dir have been removed. libpng and zlib are required.
xpm To enable support for xpm add --with-xpm-dir=DIR. If configure is not able to find the required libraries, you may add the path to your X11 libraries. As of PHP 7.4.0, use --with-xpm instead.
webp To enable support for webp add --with-webp-dir=DIR. As of PHP 7.4.0, use --with-webp instead.

Note: When compiling PHP with libpng, you must use the same version that was linked with the GD library.

Enhance the capabilities of GD to deal with different fonts by specifying the --with-XXXX configure switch to your PHP configure line.

Supported font libraries
Font libraryConfigure Switch
FreeType 2 To enable support for FreeType 2 add --with-freetype-dir=DIR. As of PHP 7.4.0 use --with-freetype instead, which relies on pkg-config.
Native TrueType string function To enable support for native TrueType string function add --enable-gd-native-ttf. (This option has no effect and has been removed as of PHP 7.2.0.)

Anonymous

5 years ago

For all who use php 7 and ubuntu

sudo apt-get install php7.0-gd

Mike K

6 years ago

On Ubuntu I was missing the libpng-dev, libjpeg-dev (and in my case) libwebp-dev libraries, all gettable with apt-get.

Also once those libraries are installed, including --with-png-dir --with-jpeg-dir --with-webp-dir, without any values (i.e. =/dir) appeared to be valid ... though admittedly I didn't try without (in case the configure script autodetected them).

msc at homofaber dot com

13 years ago

It should be noted that it might be pretty easy to install gd without the need to recompile php, when using debian:

apt-get install php5-gd

florian

11 years ago

People having difficulties setting the --with-libdir option needs to set it like this :

--with-libdir=lib64

That option works fine. Doing --with-libdir=/usr/lib64 doesn't work because the configure script prepends the --prefix option before the --with-libdir option. So, doing --with-libdir=/usr/lib64 makes the configure script to look for libs in /usr/usr/lib64, which is wrong of course, and not in /usr/lib64.

abdulbasitsaeed

3 years ago

To install PHP GD extension on an Amazon Linux AMI server, with php 7:

sudo yum install php 70-gd

Do remember to restart Apache after the installation!

sudo service httpd restart

Joseph Marlin

11 years ago

I also had to install the libgd package in addition to php5-gd:

sudo apt-get install libgd2-xpm-dev*

Qussayyon Qamaron: Qusai.zf2@gmailcom

5 years ago

#install under Ubuntu 16.04:
    * if you have access to PHP7.1:
        apt install php7.1-gd && systemctl restart apache2
    * if you have access to PHP7.0:
        apt install php7.0-gd && systemctl restart apache2

------------------------------------------------
Qussayyon Qamaron: Qusai.zf2gmailcom

elassoto at hotmail dot com

12 years ago

If you have already compiled PHP and want to recompile '--with-gd', don't forget to run 'make clean' first!

Parmjit Singh

1 year ago

Installation on Pop-os No need for php5 or php7.0 etc:

sudo apt install php-gd

octopus at logicaloctopus dot com

11 years ago

I was running PHP on a SUSE box on amazon EC2.
to get gd to work all I had to do was to run:
> yast -i php5_gd

and when that completed I just restarted apache. voila!

leyluj21 at gmail dot com

7 years ago

If you are using PHPBREW , the extension is called gd.
So you do.
```
phpbrew ext install gd
```

It will compile the extension to the core.

remalsha at gmail dot com

4 years ago

On AntergosOS ( Arch linux )

*first run >>php -v   and get current php version. In my case for PHP 7.1.14

      sudo pacman -S php71-gd

then restart you apache server using,

           sudo systemctl restart httpd

nordin74

2 years ago

Since 7.4 replace "--with-gd" by "--enable-gd"

Gabriel Torres

2 years ago

As of PHP 7.4, to enable GD you have to use --enable-gd instead of --with-gd

omni at ominsapien dot com

1 year ago

Hello. Does GD image processing allow for color spaces / color profiles to be defined or maintained from the source image? For example, if I upload a jpg with ProPhoto RGB color space with the embedded profile, will all of the subsequent processed images that are output maintain the profile? Or is there no profile and or is it changed to sRGB?

Same question goes for ImageMagick.

Thank you so much!

How do I enable GD?

Installing PHP GD in Windows.
Step 1: Install XAMPP in your windows system..
Step 2: Verify if GD is already installed or not. ... .
Step 3: Locate and open php. ... .
Step 4: Find ;extension=gd..
Step 5: Remove semicolon from ;extension=gd and save the file..
Step 6: Go to php folder. ... .
Step 7: Look for php_gd. ... .
Step 8: Copy php_gd..

How can I tell if GD is enabled in PHP?

You can check to see if the GD library is enabled by creating a simple phpinfo page on your web server..
Open your PHP. ... .
Locate the following line. ... .
Remove the preceding semicolon (;) to enable the option..
Save your file..
Restart the web server..

Which function should be run to watch that GD Support is enabled or not?

To know this we can use phpinfo function and check GD support is available or not.

What does PHP GD do?

GD is an open source code library for the dynamic creation of images. GD is used for creating PNG, JPEG and GIF images and is commonly used to generate charts, graphics, thumbnails on the fly.