Home > Article > Backend Development > Summary of image generation and processing functions related to PHP GD library
This article summarizes the image generation and processing functions related to the PHP GD library. I share it with you for your reference. The details are as follows:
In the past few days, I have been learning about image verification codes. I have referred to many examples, all of which use the GD library to generate and draw images, so I plan to encapsulate the GD library into classes for use. By the way, also learn and practice the object-oriented part of PHP.
First analyze the functions provided by the GD library and divide them according to their functions: (These are only commonly used basic-level functions, more advanced functions will be studied later)
1. create // Image generation
A. Draw image
imageCreate // 基于调色板(256色)的图像(gif/*) imageCreateTrueColor // 基于真彩色的图像(不能用来生成gif图像)
B. Create image from image
imageCreateFrom*(*=gd2/gd2part/gd/gif/jpeg/png/string/wbmp/xbm/xpm) // 从图像创建图像
C.copy
imageCopy // 复制局部图像 imageCopyMerge // 复制并合并局部图像 imageCopyMergeGray // 复制并合并局部图像(灰度) imageCopyResampled // 复制局部图像(重新采样) imageCopyResized // 复制局部图像(调整大小)
2. draw // Draw
A.point // point
imageSetPixel // 画点
B.line // Line
imageLine // 画线段 imageArc // 画椭圆弧 imageFilledArc // 画椭圆弧并填充 imageDashedLine // 画虚线
C.graph // Graph
imageEllipse // 画椭圆 imageFilledEllipse // 画椭圆并填充 imageRectangle // 画矩形 imageFilledRectangle // 画矩形并填充 imagePolygon // 画多边形 imageFilledPolygon // 画多边形并填充
D.text // Text
imageChar // 画字符(水平) imageCharUp // 画字符(垂直) imageString // 画字符串(水平) imageStringUp // 画字符串(垂直) imageTtfText // 画文本(TrueType字体) imageFtText // 画文本(FreeType2字体) imagePsText // 画文本(PostScript Type1字体)
E. fill // fill
imageFill // 填充颜色 imageFillToBorder // 填充至边界color
imageColorAllocate // 生成颜色 imageColorAllocateAlpha // 生成颜色(附加透明度)
B.show
getImageSize // 取得图像大小 getImageSizeFromString // 取得url或路径对应图像的大小 image_type_to_extension // 取得文件格式(扩展名) image_type_to_mime_type // 取得文件的MIME类型 imageColorAt // 取得某像素的颜色 imageFontWidth // 取得字体宽度 imageFontHeight // 取得字体高度 imageSx // 取得图像宽度 imageSy // 取得图像高度6. destroy // Destroy
image2Wbmp // 转换为WBMP格式并输出 jpeg2Wbmp // 将JPEG转换为WBMP格式并输出 png2Wbmp // 将PNG转换为WBMP格式并输出I hope this article will be helpful to everyone in PHP program design. For more articles related to summary of image generation and processing functions of PHP GD library, please pay attention to PHP Chinese website!