Модуль gd для php windows

Подключение GD2 к PHP

Как обычно начинаем тренироваться на локальном компьютере, а он, конечно, работает под виндами. Точнее Windows XP SP2. Далее подключим GD2 в PHP, настроенном через порты или собранным вручную под FreeBSD.

Подключение GD2 к PHP под Windows

Находим в дистрибутиве:
\php-4.3.9-Win32.zip\php-4.3.9-Win32\extensions\
библиотеку php_gd2.dll, т.е. версию 2.
и копируем php_gd2.dll в c:\windows
в файле c:\windows\php.ini находим строку extension=php_gd2.dll и убираем комментарий.
Перегружаем Апач. Всё.

Если наивным образом сначала убрать в php.ini комментарий и думать, что этого достаточно, то после перезагрузки Апача появится диагностика:
«Unable to load dynamic library ‘./php_gd.dll’ — Не найден указанный модуль.»

Подключение GD2 к PHP под FreeBSD

PHP уже инсталлирован из портов

Точнее не только PHP, но вообще всё (php, MySQL, Apache, . ) было настроено с помощью портов.

# cd /usr/ports/lang/php4-extensions # make config добавляем галочку: "GD library support" # make deinstall # make reinstall # apachectl -k graceful мягкий перезапуск или # apachectl restart грубый перезапуск

PHP собран вручную

В этом случае требуется предварительная работа по подготовке JPEG и ZLIB

Установка поддержки JPEG

JPEG из порта
# cd /usr/ports/graphics/jpeg # make получили директорию work/jpeg-6b не делать make install
JPEG из дистрибутива
# cd /usr/dist/ # wget ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz # gunzip -c jpegsrc.v6b.tar.gz | tar xf - # cd /usr/dist/jpeg-6b # ./configure # make

Надо установить поддержку zlib

Из порта
# cd /usr/ports/archivers/php4-zlib # make Libraries have been installed in: /usr/ports/archivers/php4-zlib/work/php-4.4.4/ext/zlib/modules

Собираем PHP

# cd /usr/dist/php-4.4.4 # ./configure --with-mysql --with-apache=/usr/dist/apache_1.3.37 --enable-memory-limit --with-gd без указания директории инсталлируется встроенная в PHP библиотека GD. --with-jpeg-dir=/usr/ports/graphics/jpeg/work/jpeg-6b , если jpeg из порта или /usr/dist/jpeg-6b , если jpeg из дистрибутива --with-zlib-dir=/usr/ports/archivers/php4-zlib/work/php-4.4.4/ext/zlib/modules # make install && make clean

Далее собираем новый Apache как обычно и заменяем им старый. JPEG, PNG, GIF работают.

Читайте также:  Форма бронирования билетов html

Тестирование

gif.php: png.php jpg.php: gd_info.php: KEYVAL $val ) echo "$key$val"; ?>

Пройденные ошибки

При установке библиотеки JPEG после «make» была сделана команда «make install» с расчётом, что новые файлы лягут в /usr/local и потом автоматически будут там найдены

# ./configure --with-mysql --with-apache=/usr/dist/apache_1.3.37 --enable-memory-limit --with-gd --with-jpeg-dir --with-zlib-dir=/usr/ports/archivers/php4-zlib/work/php-4.4.4/ext/zlib/modules

Но почему-то JPEG не подключился. Не было никакой отрицательной диагностики и нет результата.

По глупости я тыкался как слепой котёнок пытаясь поставить то так, то этак. То через всё встроенное, то через скаченное, то из портов. Всё это безобразие сопровождалось лишними инсталляциями от чего произошли накладки из-за которых в момент инсталляции PHP были ошибки:

# ./configure --with-mysql --with-apache=/usr/dist/apache_1.3.37 --enable-memory-limit --with-gd=/usr/local Thank you for using PHP. # make install /usr/dist/php-4.4.4/ext/gd/gd.c:1151: undefined reference to `gdImageRotate'
# ./configure --with-mysql --with-apache=/usr/dist/apache_1.3.37 --enable-memory-limit --with-gd=/usr/local --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-zlib-dir=/usr/ports/archivers/php4-zlib/work/php-4.4.4/ext/zlib/modules Thank you for using PHP. # make install . /usr/dist/php-4.4.4/ext/gd/gd.c:837: undefined reference to `gdImageColorMatch' /usr/dist/php-4.4.4/ext/gd/gd.c:1151: undefined reference to `gdImageRotate' *** Error code 1

Попытка подготовить все модули отдельно и точно указать на них:

# ./configure --with-mysql --with-apache=/usr/dist/apache_1.3.37 --enable-memory-limit --with-gd=/usr/ports/graphics/gd/work/gd-2.0.33 --with-jpeg-dir=/usr/dist/php-4.4.4/0/bin --with-zlib-dir=/usr/ports/archivers/php4-zlib/work/php-4.4.4/ext/zlib/modules ext/gd/gd.o: In function `zif_imagecolormatch': /usr/dist/php-4.4.4/ext/gd/gd.c:837: undefined reference to `gdImageColorMatch' ext/gd/gd.o: In function `zif_imagerotate': /usr/dist/php-4.4.4/ext/gd/gd.c:1151: undefined reference to `gdImageRotate' ext/gd/gd.o: In function `zif_imageline': /usr/dist/php-4.4.4/ext/gd/gd.c:2229: undefined reference to `gdImageAALine' ext/gd/gd.o: In function `zif_imageellipse': /usr/dist/php-4.4.4/ext/gd/gd.c:2372: undefined reference to `gdImageEllipse' ext/gd/gd.o: In function `zif_imageantialias': /usr/dist/php-4.4.4/ext/gd/gd.c:3906: undefined reference to `gdImageAntialias' *** Error code 1

Решение

После того, как были удалены все следы инсталляций GD, а потом всё сделано как написано вначале — всё получилось.

Ссылки по теме

Источник

Установка

Чтобы включить поддержку GD сконфигурируйте PHP с опцией —with-gd[=DIR] , где DIR — это директория установки GD. Чтобы использовать рекомендованную разработчиками встроенную версию библиотеки GD (впервые добавленную в дистрибутив в версии PHP 4.3.0), используйте опцию конфигурации —with-gd . Библиотека GD требует наличие библиотек libpng и libjpeg для компиляции.

В Windows-системах, вы должны включить модуль GD2 DLL php_gd2.dll в php.ini . Старый модуль GD1 DLL php_gd.dll был удален в версии PHP 4.3.2. Функции для работы с полноцветными изображениями, такие как imagecreatetruecolor() , требуют наличие GD2.

Повысить возможности библиотеки GD для работы с большим количеством форматов изображений можно, используя опцию —with-XXXX во время конфигурации PHP.

Поддерживаемые форматы изображений
Формат изображения Опция при конфигурировании
jpeg Чтобы включить поддержку jpeg добавьте —with-jpeg-dir=DIR . Jpeg 6b, 7 или 8 поддерживаются.
png Чтобы включить поддержку png добавьте —with-png-dir=DIR . Внимание, libpng требует наличие библиотеки zlib, поэтому добавьте —with-zlib-dir[=DIR] при конфигурации.
xpm Чтобы включить поддержку xpm добавьте —with-xpm-dir=DIR . Если во время конфигурации не удается найти необходимую библиотеку, можно указать путь к библиотеке X11.

Замечание: При компиляции PHP с libpng, вы должны использовать ту же версию libpng, с которой была собрана библиотека GD.

Повысить возможности библиотеки GD для работы с различными шрифтами можно, используя опцию —with-XXXX во время конфигурации PHP.

Поддерживаемые библиотеки шрифтов
Библиотека шрифтов Опция при конфигурировании
FreeType 2 Чтобы включить поддержку FreeType 2 добавьте —with-freetype-dir=DIR .
T1lib Чтобы включить поддержку T1lib (шрифты Postscript Type 1) добавьте —with-t1lib[=DIR] .
Native TrueType string function Чтобы включить поддержку Native TrueType string function добавьте —enable-gd-native-ttf .

Источник

How to Install PHP GD Extension on Windows WAMP and XAMPP Server

Do you need to install PHP GD Extension? Don’t worry I got you. In this post, I will share with you how to install PHP GD Extension in your windows. This extension is important if you have the functionality to create and manipulate images in PHP. Kindly follow the simple steps below.

First, check if «php_gd2.dll» is already exists in your extension web server directory. If you’re using Xampp you will find it here «C:\xampp\php\ext».

Second, if «php_gd2.dll» the extension is not yet existing kindly download it here and upload it to your web server extensions directory or here «C:\xampp\php\ext».

Third, then if the above is already checked then open the «php.ini» file to your editor which is can be found in this directory «C:\xampp\php\» then search inside the «php.ini» file.

Fourth, once you found the «extension=gd2» then if you see like this «;extension=gd2» this is commented that’s why GD extension is not enabled. Now we will enable this by removing the «;» (comma).

//change the following line ;extension=gd2 //to this extension=gd2

NOTE: If you can’t found the «extension=gd2» then you must add this line under «Dynamic Extensions» inside the «php.ini» file. Just see the following file below:

;;;;;;;;;;;;;;;;;;;;;; ; Dynamic Extensions ; ;;;;;;;;;;;;;;;;;;;;;; ; If you wish to have an extension loaded automatically, use the following ; syntax: ; ; extension=modulename ; ; For example: ; ; extension=mysqli ; ; When the extension library to load is not located in the default extension ; directory, You may specify an absolute path to the library file: ; ; extension=/path/to/extension/mysqli.so ; ; Note : The syntax used in previous PHP versions ('extension=.so' and ; 'extension='php_.dll') is supported for legacy reasons and may be ; deprecated in a future PHP major version. So, when it is possible, please ; move to the new ('extension=) syntax. ; ; Notes for Windows environments : ; ; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+) ; extension folders as well as the separate PECL DLL download (PHP 5+). ; Be sure to appropriately set the extension_dir directive. ; extension=gd2 extension=bz2 extension=curl ;extension=ffi ;extension=ftp extension=fileinfo

Fifth, now let’s restart your web server.

Once your server is already restarted then let’s check and confirm if the GD is already enabled to your web server. Now create a PHP file then name it as you want then add this code. Then run it. Then search GD Support and you will see the GD configuration. Then that’s it you have successfully installed the GD Extension.

The above steps can be useful in WAMPP and XAMPP localhost servers.

I hope this solution may help you. Thank you for reading. Happy coding 🙂

Источник

How to Install PHP GD Support on Windows Server

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 the php_gd2.dll file to the extensions directory.
  • Open the php.ini file in a text editor and check whether the php_gd2.dll extension has already been added. (;extension=php_gd2.dll)
  • If ;extension=php_gd2.dll is exists in php.ini file, enable GD extension by uncommenting the extension=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

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.

Follow the same steps mentioned above to install the PHP GD library in XAMPP or WAMP localhost server.

Источник

Оцените статью