Issue was resolved. I am using XAPP.
I tried to search for «extension=php_gd2.dll» file in «php.ini» file but there was no such thing there («;extension=php_gd2.dll» was also not there with a semicolon).
Then I included the statement «extension=php_gd2.dll» myself in php.ini file.
Also, I downloaded the the file «extension=php_gd2.dll» from https://www.dll-files.com/php_gd2.dll.html and placed it in folder «C:\xampp\php» (there is also another folder C:\xampp\php\ext where other extensions reside but anyway this method did not work).
Then I restarted Apache and MySQL from xampp-control.exe.
It did NOT work.
I RESET all the changes I made in the previous step.
Tried the other method:
opened «php.ini» file (at C:\xampp\php) and looked for «extension=gd».
I noticed that there was a semicolon present with the searched word and it appeared as «;extension=gd». I removed semicolon. Saved the php.ini file. Stopped and restarted Apache from xampp-control.exe.
Now it works.
So what exactly was resolved?
When I was selecting logo image on wordpress at Customizing ▸ Default/Basic Setting ▸ Site Identity, I was unable to crop it earlier. After following the second step, it works. Now I can crop files.
Установка
Чтобы включить поддержку GD сконфигурируйте PHP с опцией
—with-gd[=DIR], где DIR — это директория
установки GD. Чтобы использовать рекомендованную разработчиками встроенную версию
библиотеки GD, используйте опцию конфигурации
—with-gd.
Библиотека GD требует наличие библиотек libpng и
libjpeg для компиляции.
Начиная с PHP 7.4.0, —with-gd становится
—enable-gd (нужно ли вообще
включать модуль) и —with-external-gd
(чтобы выбрать использование внешнего libgd, а не встроенного).
В Windows-системах, вы должны включить модуль GD DLL php_gd.dll в php.ini.
До PHP 8.0.0, DLL-файл назывался php_gd2.dll.
Повысить возможности библиотеки GD для работы с большим количеством форматов изображений можно, используя
опцию --with-XXXX
во время конфигурации PHP.
Формат изображения | Опция при конфигурировании |
---|---|
jpeg |
Чтобы включить поддержку jpeg добавьте —with-jpeg-dir=DIR. Jpeg 6b, 7 или 8 поддерживаются. Начиная с PHP 7.4.0, используйте вместо этого —with-jpeg. |
png |
Чтобы включить поддержку png добавьте —with-png-dir=DIR. Внимание, libpng требует наличие библиотеки zlib, поэтому добавьте —with-zlib-dir[=DIR] при конфигурации. Начиная с PHP 7.4.0, были удалены —with-png-dir и —with-zlib-dir. Теперь libpng и zlib обязательны. |
xpm |
Чтобы включить поддержку xpm добавьте —with-xpm-dir=DIR. Если во время конфигурации не удаётся найти необходимую библиотеку, можно указать путь к библиотеке X11. Начиная с PHP 7.4.0, используйте вместо этого —with-xpm. |
webp |
Чтобы включить поддержку webp, добавьте —with-webp-dir=DIR. |
Замечание:
При компиляции PHP с libpng, вы должны использовать ту же версию libpng, с которой была собрана
библиотека GD.
Повысить возможности библиотеки GD для работы с различными шрифтами можно, используя
опцию --with-XXXX
во время конфигурации PHP.
Библиотека шрифтов | Опция при конфигурировании |
---|---|
FreeType 2 |
Чтобы включить поддержку FreeType 2 добавьте —with-freetype-dir=DIR. Начиная с PHP 7.4.0, используйте вместо этого опцию —with-freetype , которая зависит от pkg-config. |
Native TrueType string function |
Чтобы включить поддержку Native TrueType string function добавьте —enable-gd-native-ttf. (Параметр не имеет никакого эффекта и был удалён в PHP 7.2.0.) |
Anonymous ¶
6 years ago
For all who use php 7 and ubuntu
sudo apt-get install php7.0-gd
james dot a dot munsch at gmail dot com ¶
9 years ago
sudo apt-get install php5-gd && sudo service apache2 restart
To install under Ubuntu 14.04.
florian ¶
12 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 ¶
4 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
msc at homofaber dot com ¶
14 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
fabrizzio at webtux dot cl ¶
4 years ago
php --version if result is 7.2 version
sudo apt-get install php7.2-gd
Mike K ¶
7 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).
oskari at cellarcode dot com ¶
3 months ago
Note if you have php-fpm installed, you have to restart the service for the installation to show up in phpinfo output...
systemctl restart php-fpm (or equivalent)
Qussayyon Qamaron: Qusai.zf2@gmailcom ¶
6 years ago
#install under Ubuntu 16.04:
* if you have access to PHP7.1:
<sudo> apt install php7.1-gd && <sudo> systemctl restart apache2
* if you have access to PHP7.0:
<sudo> apt install php7.0-gd && <sudo> systemctl restart apache2
------------------------------------------------
Qussayyon Qamaron: Qusai.zf2gmailcom
Joseph Marlin ¶
12 years ago
I also had to install the libgd package in addition to php5-gd:
sudo apt-get install libgd2-xpm-dev*
tecknovice at gmail dot com ¶
3 years ago
currently is php7.2-gd
sudo apt install php7.2-gd
leyluj21 at gmail dot com ¶
8 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.
elassoto at hotmail dot com ¶
13 years ago
If you have already compiled PHP and want to recompile '--with-gd', don't forget to run 'make clean' first!
boly38 at gmail dot com ¶
12 years ago
octopus at logicaloctopus dot com ¶
12 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!
Parmjit Singh ¶
2 years ago
Installation on Pop-os No need for php5 or php7.0 etc:
sudo apt install php-gd
remalsha at gmail dot com ¶
5 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
alejo dot jm at gmail dot com ¶
11 years ago
On Macox lion with mac port just use:
sudo port install php5-gd
nordin74 ¶
3 years ago
Since 7.4 replace "--with-gd" by "--enable-gd"
Gabriel Torres ¶
3 years ago
As of PHP 7.4, to enable GD you have to use --enable-gd instead of --with-gd
theonestep4 at gmail dot com ¶
6 years ago
To install on CentOS:
yum install php-gd
omni at ominsapien dot com ¶
2 years 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!
GD is an open-source code library that is required to create and manipulate images in PHP. It is used for creating PNG, JPEG, and GIF images. It is commonly used to create charts, graphics, thumbnails, etc, and website development is the most common application of GD. It was originally developed by Thomas Boutell and is now maintained by Pierre-A. Joye under the umbrella of PHP.net. The GD library support should be enabled for working with image functions in PHP. In this article we will learn how to install PHP GD in windows:
Installing PHP GD in Windows
To install the PHP GD follow the following steps:
Step 1: Install XAMPP in your windows system.
Step 2: Verify if GD is already installed or not. So to verify GD we need to follow the following steps:
- Open XAMPP and click on the start button in front of Apache and MySQL to start php server, and go to the admin.
- A web page will open. Go to the ‘PHPInfo’ option on the top of the page.
- A PHPInfo dashboard will open up.
- Scroll down the page and search for ‘gd’. If present, GD is already installed.
If ‘gd’ is not present on the phpinfo page, you can follow the next to install GD.
Step 3: Locate and open php.ini in your editor.
Step 4: Find ;extension=gd.
Step 5: Remove semicolon from ;extension=gd and save the file.
Step 6: Go to php folder. It is usually present in C:\xampp.
Step 7: Look for php_gd.dll in the ext folder.
Step 8: Copy php_gd.dll and paste it into the following folder.
C:\Windows\System32
Step 9: Restart the XAMPP server. Now use the phpinfo() method as mentioned in step 2 to check whether the GD library is installed in the PHP server. It will show information about the PHP’s configuration.
Last Updated :
30 Jan, 2022
Like Article
Save Article
Issue was resolved. I am using XAPP.
I tried to search for «extension=php_gd2.dll» file in «php.ini» file but there was no such thing there («;extension=php_gd2.dll» was also not there with a semicolon).
Then I included the statement «extension=php_gd2.dll» myself in php.ini file.
Also, I downloaded the the file «extension=php_gd2.dll» from https://www.dll-files.com/php_gd2.dll.html and placed it in folder «C:\xampp\php» (there is also another folder C:\xampp\php\ext where other extensions reside but anyway this method did not work).
Then I restarted Apache and MySQL from xampp-control.exe.
It did NOT work.
I RESET all the changes I made in the previous step.
Tried the other method:
opened «php.ini» file (at C:\xampp\php) and looked for «extension=gd».
I noticed that there was a semicolon present with the searched word and it appeared as «;extension=gd». I removed semicolon. Saved the php.ini file. Stopped and restarted Apache from xampp-control.exe.
Now it works.
So what exactly was resolved?
When I was selecting logo image on wordpress at Customizing ▸ Default/Basic Setting ▸ Site Identity, I was unable to crop it earlier. After following the second step, it works. Now I can crop files.
The GD library is required to create and manipulate images in PHP. You need to enable GD library support for working with image functions in PHP. Here we’ll show you how to install GD library in PHP on Windows server.
In order to install PHP GD support on Windows server, follow the below steps.
- At first make sure the
php_gd2.dll
file is exists in extensions directory of PHP folder. - If
php_gd2.dll
file is not present in extensions directory, download it from here and insert thephp_gd2.dll
file to the extensions directory. - Open the
php.ini
file in a text editor and check whether thephp_gd2.dll
extension has already been added. (;extension=php_gd2.dll) - If
;extension=php_gd2.dll
is exists inphp.ini
file, enable GD extension by uncommenting theextension=php_gd2.dll
line. Uncomment can be done by deleting the leading;
from the extension.// change the following line from ... ;extension=php_gd2.dll // ... to extension=php_gd2.dll
- To include
php_gd2.dll
as an extension, add the following line inphp.ini
.extension=php_gd2.dll
- Restart the Windows server.
Use the phpinfo() method to check whether the GD library is installed in the PHP server. It will display information about the PHP’s configuration. Search for GD Support, you’ll see the information about the GD configuration.
<?php phpinfo(); ?>
Follow the same steps mentioned above to install the PHP GD library in XAMPP or WAMP localhost server.