Home > Article > Backend Development > Complete collection of PHP GD library functions (collection)
Share the commonly used functions in the php gd library, with Chinese comments and classification processing, including image information, new/loading images, output images and other php gd library functions. Friends in need can refer to them.
Contents of this section: A complete list of functions of the php gd library. 1. Image information: gd_info: Get information about the currently installed GD library imagetypes returns the image types supported by the current PHP version image_type_to_extension gets the file suffix of the image type image_type_to_mime_type gets the MIME type of the image type getimagesize Get image size imagesx gets image width imagesy gets image height imageistruecolor checks whether the image is a true color image2. Create new/load image: imagecreate — Create a new palette-based image imagecreatefromgd2 — Create a new image from a GD2 file or URL imagecreatefromgd2part — Create a new image from a part of the given GD2 file or URL imagecreatefromgd — Create a new image from a GD file or URL imagecreatefromgif — Create a new image from a GIF file or URL imagecreatefromjpeg — Create a new image from a JPEG file or URL imagecreatefrompng — Create a new image from a PNG file or URL imagecreatefromstring — Create an image from an image stream in a string imagecreatefromwbmp — Create a new image from a WBMP file or URL imagecreatefromxbm — Create a new image from an XBM file or URL imagecreatefromxpm — Create a new image from an XPM file or URL imagecreatetruecolor — Create a new true color image3, output image: image2wbmp Outputs images in WBMP format to a browser or file imagegd2 Output GD2 images to a browser or file imagegd Output GD images to a browser or file imagegif Outputs an image in GIF format to a browser or file imagewbmp Outputs images in WBMP format to a browser or file imagexbm outputs XBM images to a browser or file imagejpeg Outputs an image in JPEG format to a browser or file imagepng Outputs an image in PNG format to a browser or file4, Miscellaneous related: imagealphablending sets the color blending mode of the image imageantialias Whether to use the anti-aliasing (antialias) function imageinterlace Activate or disable interlacing imagegammacorrect applies gamma correction to GD images iptcembed embeds binary IPTC data into a JPEG image iptcparse parses binary IPTC http://www.iptc.org/ chunks into individual tokens imagesavealpha Set flag to save full alpha channel information when saving PNG images (as opposed to a single transparent color)5, graphics related: imagearc draws elliptical arc imageconvolution uses coefficients div and offset to apply for a 3x3 convolution matrix imagedashedline draw a dotted line imageellipse draws an ellipse imagerectangle draws a rectangle imagefilledarc draws an elliptical arc and fills it imagefilledellipse draws an ellipse and fills it imagefilledpolygon draws a polygon and fills it imagefilledrectangle draws a rectangle and fills it imagesetbrush sets the brush image used for drawing lines imagesetpixel draws a single pixel imagesetstyle sets the style of line drawing imagesethickness sets the width of the line drawing imagepolygon draws a polygon imageline draws a line segment6, character/font related: imagechar draws a character horizontally imagecharup draws a character vertically imagestring draws a line of string horizontally imagestringup draws a line of string vertically imagepsbbox gives a text box using PostScript Type1 font imagepsencodefont changes the character encoding vector in the font imagepsextendfont expands or condenses fonts imagepsfreefont Frees the memory occupied by a PostScript Type 1 font imagepsloadfont loads a PostScript Type 1 font from a file imagepsslantfont tilts a font imagepstext draws text strings on images using PostScript Type1 fonts imagettfbbox Gets the range of text using TrueType fonts imagettftext writes text to an image using TrueType fonts imageftbbox gives a text box using FreeType 2 fonts imagefttext Write text to an image using FreeType 2 fonts imagefontheight gets the font height imagefontwidth gets the font width imageloadfont loads a new font7, color related: imagecolorallocate assigns a color to an image imagecolorallocatealpha assigns color + alpha to an image imagecolorat gets the color index value of a pixel imagecolorclosest Gets the index value of the color closest to the specified color. Gets the color index value of a certain pixel. imagecolorclosestalpha Gets the color closest to the specified color plus transparency imagecolorclosesthwb Gets the black and white index of the hue closest to the given color imagecolordeallocate cancels the allocation of image color imagecolorexact gets the index value of the specified color imagecolorexactalpha Gets the index value of the specified color plus transparency imagecolormatch makes the palette version of colors in an image more closely match the true color version imagepalettecopy copies a palette from one image to another imagecolorresolve Gets the index value of the specified color or the closest possible replacement value imagecolorresolvealpha Gets the index value of the specified color + alpha or the closest alternative possible imagecolorset sets the color for the specified palette index imagecolorsforindex gets the color of an index imagecolorstotal Gets the number of colors in the palette of an image imagecolortransparent defines a color as transparent8, Image operation: imagecopy copies part of an image imagecopymerge copies and merges part of an image imagecopymergegray copies and merges part of an image in grayscale imagecopyresampled resamples copy part of the image and resizes it imagecopyresized copies part of the image and resizes it imagerotate rotates an image by a given angle jpeg2wbmp Converts JPEG image files to WBMP image files png2wbmp Converts PNG image files to WBMP image files imagedestroy destroys an image1 2 Next Page Last Page |