Home >Backend Development >PHP Tutorial >Introduction to PHP's GD library functions What is the GD library? _PHP Tutorial
What is the gd library?
The gd library is an extension library for PHP to process graphics. The gd library provides a series of APIs for processing images. You can use the GD library to process images or generate images. On websites, the GD library is usually used to generate thumbnails or to add watermarks to images or to generate reports on website data.
GetImageSize
Function: Get the size of the image [i.e. length and width] Usage: array GetImageSize(string filename, array [imageinfo]);
ImageArc
Function: Draw an arc Usage: int ImageArc(int im, int cx, int cy, int w, int h, int s, int e, int col);
ImageChar
Function: Write horizontal characters Usage: int ImageChar(int im, int font, int x, int y, string c, int col);
ImageCharUp
Function: Write vertical characters Usage: int ImageCharup(int im, int font, int x, int y, string c, int col);
ImageColorAllocate
Function: Match colors Usage: int ImageColorAllocate(int im, int red, int green, int blue);
ImageColorTransparent
Function: Specify a transparent background color. Usage: int ImageColorTransparent(int im, int [col]);
ImageCopyResized
Usage: Copy a new image and resize it. Usage: 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
Function: Create a new image Usage: int ImageCreate(int x_size, int y_size ; :int ImageDestroy(int im);
ImageFill
Function: Graphic coloring Usage: int ImageFill(int im, int x, int y, int col);
ImageFilledPolygon Function: Polygon Area shading usage: int ImageFilledPolygon(int im, array points, int num_points, int col);
ImageFilledRectangle Function: rectangular area shading usage: int ImageFilledRectangle(int im, int x1, int y1, int x2, int y2, int col);
ImageFillToBorder Function: Coloring within the specified color area Usage: int ImageFillToBorder(int im, int x, int y, int border, int col);
ImageFontHeight
Function: Get the height of the font. Usage: int ImageFontHeight(int font);
ImageFontWidth. Function: Get the width of the font. Usage: int ImageFontWidth(int font);
ImageInterlace. Function: Use Interlaced display or not Usage: int ImageInterlace(int im, int [interlace]);
ImageLine Function: Draw a solid line Usage: int ImageLine(int im, int x1, int y1, int x2, int y2 , int col);
ImageLoadFont Function: Load bitmap font Usage: int ImageLoadFont(string file);
ImagePolygon Function: Draw polygon Usage: int ImagePolygon(int im, array points , int num_points, int col);
ImageRectangle Function: draw a rectangle Usage: int ImageRectangle(int im, int x1, int y1, int x2, int y2, int col);
ImageSetPixel Function: draw points Usage: int ImageSetPixel(int im, int x, int y, int col); ImageString Function: draw horizontal string Usage: int ImageString(int im, int font, int x, int y, string s, int col);
ImageStringUp Function: Draw straight string Usage: int ImageStringUp(int im, int font, int x, int y, string s, int col);
ImageSX
Function: Get the width of the image. Usage: int ImageSX(int im);
ImageSY
Function: Get the height of the image. Usage: int ImageSY(int im);
ImageTTFBBox
Function: Calculate the area occupied by TTF text Usage: array ImageTTFBBox(int size, int angle, string fontfile, string text);
ImageTTFText Function: Write TTF text into the image Usage: array ImageTTFText(int im , int size, int angle, int x, int y, int col, string fontfile, string text); ImageColorAt Function: Get the index value of the color of the specified point in the picture Usage: int ImageColorAt(int im, int x, int y);
ImageColorClosest
Function: Calculate the color in the color table that is closest to the specified color Usage: int ImageColorClosest(int im, int red, int green, int blue);
ImageColorExact
Function: Calculate the specified color index value on the color table Usage: int ImageColorExact(int im, int red, int green, int blue);
ImageColorResolve
Function: Calculate the specified or closest color on the color table Index value usage: int ImageColorResolve(int im, int red, int green, int blue);
ImageColorSet
Function: Set the color of the specified index on the color table. Usage: boolean ImageColorSet(int im, int index, int red, int green, int blue); ImageColorsForIndex Function: Get the color of the specified index on the color table Usage: array ImageColorsForIndex(int im, int index);
ImageColorsTotal
Function: Calculate the graph Color number usage: int ImageColorsTotal(int im); ImagePSLoadFont Function: Load PostScript Font usage: int ImagePSLoadFont(string filename);
ImagePSFreeFont
Function: Remove PostScript Font usage: void ImagePSFreeFont( int fontindex);
ImagePSEncodeFont
Function: Convert PostScript font to vector word Usage: int ImagePSEncodeFont(string encodingfile);
ImagePSText Function: Write PostScript text into the image Usage: 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 Function: Calculate the area occupied by PostScript text Usage: array ImagePSBBox(string text, int font, int size, int space, int width, float angle);
ImageCreateFromPNG Function: Take out PNG graphic usage: int ImageCreateFromPng(string filename);
ImagePNG Function: create PNG Graphic usage: int ImagePng(int im, string [filename]);
ImageCreateFromGIF Function: take out GIF Graphic usage: int ImageCreateFromGif(string filename);
ImageGIF Function: Create GIF Graphic usage: int ImageGif(int im, string [filename]);