PHP provides a wealth of image processing functions, mainly including:
function | describe |
---|---|
gd_info() | Get information about the currently installed GD library |
getimagesize() | Get image information |
getimagesizefromstring() | Get image information |
image_type_to_extension() | Get image suffix |
image_type_to_mime_type() | Returns the MIME type of the image |
image2wbmp() | Output WBMP pictures |
imageaffine() | Returns the image after affine transformation |
imageaffinematrixconcat() | Concatenate two matrices |
imageaffinematrixget() | Get matrix |
imagealphablending() | Set the color blending mode of an image |
imageantialias() | Whether to use antialiasing (antialias) function |
imagearc() | Draw elliptical arc |
imagechar() | Write horizontal characters |
imagecharup() | Draw a character vertically |
imagecolorallocate() | Assign a color to an image |
imagecolorallocatealpha() | Assign color and transparency to an image |
imagecolorat() | Get the color index value of a pixel |
imagecolorclosest() | Gets the index value of the color closest to the specified color |
imagecolorclosestalpha() | Gets the index of the color closest to the specified color plus transparency |
imagecolorclosesthwb() | Gets the index of the black and white color closest to the specified color |
imagesx(), imagesy() | Get image width and height |
To use PHP image processing functions, you need to load the GD support library. Please make sure php.ini loads the GD library:
On Windows server:
extension=php_gd2.dll
On Linux and Mac systems:
extension=php_gd2.so
Use the gd_info() function to view information about the currently installed GD library:
<?phpvar_dump(gd_info());?>
The output is roughly as follows:
array(12) { ["GD Version"]=> string(26) "bundled (2.1.0 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(false) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPEG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(false) [" XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false)}