PHP GD Library functions Daquan (Favorites)

Source: Internet
Author: User
Tags bmp image transparent color rotate image
Share the PHP GD library commonly used functions, with Chinese comments, and do a classification processing, including image information, new/loaded images, output images, such as PHP GD library functions, with the needs of friends reference.

This section: PHP GD library functions Daquan.

1, image information:

Gd_info get information about the currently installed GD library Imagetypes returns the image type supported by the current PHP version image_type_to_extension obtain the file suffix of the image type Image_type_to_mime_type obtained The MIME type of the image type getimagesize gets the image size Imagesx obtains the image width Imagesy obtains the image height Imageistruecolor checks whether the image is true color image

2. New/Loaded 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 given GD2 file or part of a URL createfromgd-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 imagecr eatefrompng-Create a new image from a PNG file or URL imagecreatefromstring-create a new image from an image stream in a string imagecreatefromwbmp-create a new image from a WBMP file or URL Imagecrea tefromxbm-Create a new image from a XBM file or URL imagecreatefromxpm-create a new image from the XPM file or URL imagecreatetruecolor-create a new true color image

3, Output Image:

Image2wbmp output the image to a browser or file in WBMP format IMAGEGD2 output the GD2 image to a browser or file IMAGEGD export the GD image to a browser or file Imagegif export the image to a browser or file Imagewbmp in GIF format to WBMP format prints an image to a browser or file IMAGEXBM output the XBM image to a browser or file imagejpeg output the image to a browser or file in JPEG format imagepng export the image to a browser or file in PNG format

4, Miscellaneous Related:

Imagealphablending Setting the image's color-blending mode Imageantialias whether to use anti-aliasing (AntiAlias) to imageinterlace activate or disallow interlaced imagegammacorrect for GD image applications Gamma correction iptcembed embeds binary IPTC data into a JPEG image iptcparse resolves the binary IPTC http://www.iptc.org/block to a single tag Imagesavealpha set tag to save the PNG map Preserve full alpha channel information (as opposed to a single transparent color)

5, Graphics Related:

IMAGEARC Draw Elliptical arc imageconvolution with coefficients div and offset apply a 3x3 convolution matrix Imagedashedline draw a dashed imageellipse draw an ellipse imagerectangle draw a rectangle IM AGEFILLEDARC draw an elliptical arc and fill the imagefilledellipse to draw an ellipse and fill the imagefilledpolygon to draw a polygon and fill the Imagefilledrectangle Draw a rectangle and fill Imagesetbrush set the drawing line with a brush image imagesetpixel draw a single pixel Imagesetstyle set the style of the line imagesetthickness set the width of the drawing line Imagepolygon Draw a polygon Imageline draw a line segment

6, character/font-related:

Imagechar draw a character horizontally imagecharup vertically to draw a character imagestring horizontally to draw a line of string Imagestringup vertically to draw a line of string Imagepsbbox give a use PostScript Type1 Font text box imagepsencodefont change character encoding vector in font imagepsextendfont expand or thin font Imagepsfreefont release a PostScript Type 1 The memory occupied by the font Imagepsloadfont loads a PostScript Type 1 font from a file Imagepsslantfont tilts a font imagepstext with PostScript Type1 A font draws a text string on an image Imagettfbbox the range of text that uses TrueType fonts Imagettftext writes text to an image using a TrueType font Imageftbbox gives a FreeType 2 Font text box Imagefttext write text to an image using FreeType 2 font imagefontheight get font height imagefontwidth get font width imageloadfont load a new font

7, Color Related:

Imagecolorallocate assigns a color to an image Imagecolorallocatealpha assigns a color to an image + Alphaimagecolorat gets the color index value of a pixel imagecolorclosest Gets the index value of the color closest to the specified color to get the color index value of a pixel Imagecolorclosestalpha gets the color that is closest to the specified color and transparency IMAGECOLORCLOSESTHWB Gets the black-white index closest to the given color imagecolordeallocate the image color assignment imagecolorexact Gets the index value of the specified color Imagecolorexactalpha Gets the index value of the specified color plus transparency Imagecolormatch makes the color of the palette version in one image match the true Color version imagepalettecopy copies the palette from one image to another imagecolorresolve Gets the index value of the specified color or possibly the nearest alternative value Imagecolorresolvealpha gets the index value of the specified color + alpha or the nearest alternative value that may be obtained 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 a transparent color

8, image operation:

Imagecopy part of a copy image Imagecopymerge copy and merge part of the image Imagecopymergegray copy and merge portions of the image in grayscale imagecopyresampled Resample Copy part image and resize imagecopyresized copy part of image and resize imagerotate rotate image at given angle jpeg2wbmp convert JPEG image file to WBMP image file Png2wbmp convert PNG image file to W BMP image file Imagedestroy destroy an image

1 2 Next last page

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.