search
HomeBackend DevelopmentPHP ProblemWhat should I do if php does not support the gd library?

The solution to the problem that php does not support the gd library: first find and open the "php.ini" file; then open the content and find ";extension=php_gd2.dll"; then remove the leading semicolon; finally Just save the changes.

What should I do if php does not support the gd library?

Recommended: "PHP Tutorial"

Enable PHP GD library support under Windows

Find php.ini, open the content, find:

;extension=php_gd2.dll

Remove the semicolon ";" at the front, and then save it. If there is no semicolon in the first place, it means it has been turned on. .

Enable PHP GD library support under Linux

#开启GD库支持有以下几种方法
##检测GD库是否安装命令
php5 -m | grep -i gd

or

php -i | grep -i --color gd
##如未安装GD库,则为服务器安装,方法如下
### 如果是源码安装,则加入参数
--with-gd
### 如果是debian系的linux系统,用apt-get安装,如下
apt-get install php5-gd
### 如果是CentOS系的系统,用yum安装,如下
yum install php-gd
### 如果是suse系的linux系统,用yast安装,如下
yast -i php5_gd
### 如果嫌这个世界不够蛋疼呢,可以在原先编译PHP不支持GD的情况下附加

First download the zlib source code, libpng source code, and gd source code

After decompressing, go to the source code directory

zlib directory

./configure --prefix=/usr/local/zlib
make ; make install
make clean

libpng directory

cp scripts/makefile.linux ./makefile
./configure --prefix=/usr/local/libpng
make ; make install
make clean

gd directory

./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng
make ; make install
make clean

Finally, in php.ini, search for [gd ], add a line

extension=/usr/local/libgdgd.so

below and restart the php service. If it doesn’t work, try reboot

, but as a final reminder, you must know that there are many unexpected things in this world, source code installation, In the case of only adding the gd library, the PHP version and the library version are different

, so:

- There is no guarantee that there will be returns after so much effort

- There is no guarantee that gd.so can be loaded successfully

- There is no guarantee that it will not become pregnant

So if it is a source code installation, it is best to add the parameter --with-gd

# when compiling PHP

##GD library function

GetImageSize
作用:取得图片的大小[即长与宽] 用法:array GetImageSize(string filename, array [imageinfo]);
ImageArc
作用:画弧线 用法:int ImageArc(int im, int cx, int cy, int w, int h, int s, int e, int col);
ImageChar
作用:写出横向字符 用法:int ImageChar(int im, int font, int x, int y, string c, int col);
ImageCharUp
作用:写出竖式字符 用法:int ImageCharup(int im, int font, int x, int y, string c, int col);
ImageColorAllocate
作用:匹配颜色 用法:int ImageColorAllocate(int im, int red, int green, int blue);
ImageColorTransparent
作用:指定透明背景色 用法:int ImageColorTransparent(int im, int [col]);
ImageCopyResized
作用:复制新图并调整大小 用法:int ImageCopyResized(int dst_im, int src_im, int dstX, int dstY, int srcX,
int srcY, int dstW, int dstH, int srcW, int srcH);
ImageCreate
作用:建立新图 用法:int ImageCreate(int x_size, int y_size);
ImageDashedLine
作用:绘虚线 用法:int ImageDashedLine(int im, int x1, int y1, int x2, int y2, int col);
ImageDestroy 作用:结束图形 用法解释:int ImageDestroy(int im);
ImageFill
作用:图形着色 用法:int ImageFill(int im, int x, int y, int col);
ImageFilledPolygon作用:多边形区域着色 用法:int ImageFilledPolygon(int im, array points, int num_points,
int col);
ImageFilledRectangle作用:矩形区域着色 用法:int ImageFilledRectangle(int im, int x1, int y1, int x2, int
y2, int col);
ImageFillToBorder作用:指定颜色区域内着色 用法:int ImageFillToBorder(int im, int x, int y, int border,
int col);
ImageFontHeight
作用:取得字型的高度 用法:int ImageFontHeight(int font);
ImageFontWidth作用:取得字型的宽度 用法:int ImageFontWidth(int font);
ImageInterlace作用:使用交错式显示与否 用法:int ImageInterlace(int im, int [interlace]);
ImageLine作用:绘实线 用法:int ImageLine(int im, int x1, int y1, int x2, int y2, int col);
ImageLoadFont作用:载入点阵字型 用法:int ImageLoadFont(string file);
ImagePolygon作用:绘多边形 用法:int ImagePolygon(int im, array points, int num_points, int col);
ImageRectangle作用:绘矩形 用法:int ImageRectangle(int im, int x1, int y1, int x2, int y2, int col);
ImageSetPixel作用:绘点 用法:int ImageSetPixel(int im, int x, int y, int col); ImageString 作用:绘横式
字符串 用法:int ImageString(int im, int font, int x, int y, string s, int col);
ImageStringUp作用:绘直式字符串 用法:int ImageStringUp(int im, int font, int x, int y, string s, int
col);
ImageSX
作用:取得图片的宽度 用法:int ImageSX(int im);
ImageSY
作用:取得图片的高度 用法:int ImageSY(int im);
ImageTTFBBox
作用:计算 TTF 文字所占区域 用法:array ImageTTFBBox(int size, int angle, string fontfile, string text);
ImageTTFText作用:写 TTF 文字到图中 用法:array ImageTTFText(int im, int size, int angle, int x, int y,
int col, string fontfile, string text); ImageColorAt 作用:取得图中指定点颜色的索引值 用法:int
ImageColorAt(int im, int x, int y);
ImageColorClosest
作用:计算色表中与指定颜色最接近者 用法:int ImageColorClosest(int im, int red, int green, int blue);
ImageColorExact
作用:计算色表上指定颜色索引值 用法:int ImageColorExact(int im, int red, int green, int blue);
ImageColorResolve
作用:计算色表上指定或最接近颜色的索引值 用法:int ImageColorResolve(int im, int red, int green, int
blue);
ImageColorSet
作用:设定色表上指定索引的颜色 用法:boolean ImageColorSet(int im, int index, int red, int green, int
blue); ImageColorsForIndex 作用:取得色表上指定索引的颜色 用法:array ImageColorsForIndex(int im, int
index);
ImageColorsTotal
作用:计算图的颜色数 用法:int ImageColorsTotal(int im); ImagePSLoadFont 作用:载入 PostScript 字型 用法
:int ImagePSLoadFont(string filename);
ImagePSFreeFont
作用:卸下 PostScript 字型 用法:void ImagePSFreeFont(int fontindex);
ImagePSEncodeFont
作用:PostScript 字型转成向量字 用法:int ImagePSEncodeFont(string encodingfile);
ImagePSText作用:写 PostScript 文字到图中 用法:array ImagePSText(int image, string text, int font, int
size, int foreground, int background, int x, int y, int space, int tightness, float angle, int
antialias_steps);
ImagePSBBox作用:计算 PostScript 文字所占区域 用法: array ImagePSBBox(string text, int font, int size,
int space, int width, float angle);
ImageCreateFromPNG作用:取出 PNG 图型 用法:int ImageCreateFromPng(string filename);
ImagePNG作用:建立 PNG 图型 用法:int ImagePng(int im, string [filename]);
ImageCreateFromGIF作用:取出 GIF 图型 用法:int ImageCreateFromGif(string filename);
ImageGIF作用:建立 GIF 图型 用法:int ImageGif(int im, string [filename]);

The above is the detailed content of What should I do if php does not support the gd library?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
ACID vs BASE Database: Differences and when to use each.ACID vs BASE Database: Differences and when to use each.Mar 26, 2025 pm 04:19 PM

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

PHP Secure File Uploads: Preventing file-related vulnerabilities.PHP Secure File Uploads: Preventing file-related vulnerabilities.Mar 26, 2025 pm 04:18 PM

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

PHP Input Validation: Best practices.PHP Input Validation: Best practices.Mar 26, 2025 pm 04:17 PM

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

PHP API Rate Limiting: Implementation strategies.PHP API Rate Limiting: Implementation strategies.Mar 26, 2025 pm 04:16 PM

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

PHP Password Hashing: password_hash and password_verify.PHP Password Hashing: password_hash and password_verify.Mar 26, 2025 pm 04:15 PM

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.Mar 26, 2025 pm 04:13 PM

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

PHP XSS Prevention: How to protect against XSS.PHP XSS Prevention: How to protect against XSS.Mar 26, 2025 pm 04:12 PM

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

PHP Interface vs Abstract Class: When to use each.PHP Interface vs Abstract Class: When to use each.Mar 26, 2025 pm 04:11 PM

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.