Latest web development tutorials

PHP Image Processing

PHP provides rich image processing functions, including:

function description
gd_info () Access to information currently installed GD library
getimagesize () Get image information
getimagesizefromstring () Get image information
image_type_to_extension () Get Picture suffix
image_type_to_mime_type () Returns the MIME type of image
image2wbmp () Output WBMP image
imageaffine () Back after the image after affine transformation
imageaffinematrixconcat () Connecting the two matrices
imageaffinematrixget () Get Matrix
imagealphablending () Setting the image blending mode
imageantialias () Whether to use anti-aliasing (antialias) function
imagearc () Videos elliptical arcs
imagechar () Write transverse character
imagecharup () Draw a character vertically
imagecolorallocate () Assign a color to an image
imagecolorallocatealpha () Assign a color and transparency of an image
imagecolorat () Get color value of a pixel index
imagecolorclosest () Get the index of the color closest to the specified color
imagecolorclosestalpha () Index specified color + alpha acquires closest color
imagecolorclosesthwb () Black and white made with the specified color index closest chromaticity
imagesx (), imagesy () Get image width and height

GD library

Use PHP image processing functions, you need to load GD library support. Make sure php.ini loaded GD library:

Window server:

extension = php_gd2.dll

Linux and Mac systems:

extension =

Use gd_info () function to view information about the currently installed GD library:


Output is as follows:

array(12) {
  ["GD Version"]=>
  string(26) "bundled (2.1.0 compatible)"
  ["FreeType Support"]=>
  ["FreeType Linkage"]=>
  string(13) "with freetype"
  ["T1Lib Support"]=>
  ["GIF Read Support"]=>
  ["GIF Create Support"]=>
  ["JPEG Support"]=>
  ["PNG Support"]=>
  ["WBMP Support"]=>
  ["XPM Support"]=>
  ["XBM Support"]=>
  ["JIS-mapped Japanese Font Support"]=>