Skip to content
Related Articles
Open in App
Not now

Related Articles

PHP Image Processing and GD Functions Complete Reference

Improve Article
Save Article
  • Last Updated : 24 Jan, 2023
Improve Article
Save Article

Image processing and GD functions are used to create and manipulate image files in different image formats including GIF, PNG, JPEG, WBMP, and XPM. PHP can deliver the output image directly to the browser. The image processing and GD functions are used to compile the image functions for this work. It can also require other libraries, depending on the image formats. 

Example: This example illustrates the imagecolorclosesthwb() functions in PHP.

PHP




<?php
 
// Create new image from given URL
$image = imagecreatefromgif(
 
// Display the index of color
echo 'Hue White and Blackness closest color index: '
    . imagecolorclosesthwb($image, 5, 165, 10);
 
imagedestroy($image);
?>

Output:

Hue White and Blackness closest color index: 42

The list of Image processing and GD s are given below:

Functions  

Description

gd_info() Retrieve information about the currently installed GD library.
getimagesize() Get the size of an image.
getimagesizefromstring() Get the size of an image from a string.
imagealphablending() Set the blending mode for an image
imagearc() Create an arc of a circle centered at the given coordinates.
imagechar() Draw a character horizontally.
imagecharup() Draw a character vertically.
imagecolorallocate() Set the color in an image.
imagecolorallocatealpha() Allocate the color for an image.
imagecolorat() Get the index of the color of the pixel.
imagecolorclosest() Get the index of the closest color in the given image.
imagecolorclosestalpha() Get the index of closest color with alpha value in the given image
imagecolorclosesthwb() Get the index of the color hue, white and blackness in the given image.
imagecolorexact() Get the index of specified color in the palette of the image.
imagecolormatch() Make the color of palette version of an image more closely match the true color version.
imagecolorresolve() get the index of the specified color or its closest possible alternative color.
imagecolorresolvealpha() Get the index of the specified color and alpha value or its closest possible alternative value. 
imagecolorset() Set the color for the specified palette index
imagecolorsforindex() Get the colors at the given index. 
imagecolorstotal() Find the number of colors in an image‚Äôs palette. 
imagecolortransparent() Define color as transparent
imageconvolution() Modify the image content.
imagecopy() Copy the image or part of image
imagecopymerge() Copy and merge the image into a single image.
imagecopymergegray() Copy and merge the part of an image with a gray scale.
imagecreate() It is used to create a new image. 
imagecreatetruecolor() It is used to create a new true-color image.
imagecrop() Crop an image to the given rectangle.
imagedashedline() It is used to draw a dashed line. 
imagefill() It is used to fill the image with the given color. 
imagefilledarc() Draws a partial arc centered at the specified coordinate in the given image.
imagefilledellipse() It is used to draw the filled ellipse.
imagefilledrectangle() It is used to create a filled rectangle.
imageflip() Flip an image horizontally, vertically or both horizontally and vertically using the given mode.
imagegif() Create the GIF image file from the given image. 
imagelayereffect() Set the alpha blending flag to use layering effects.
imagepolygon() It is used to draw a polygon. 
imagerectangle() It  is used to draw the rectangle.
imagetruecolortopalette() Convert a true color image to a palette image.
imagesetthickness() Set the thickness for line drawing.
imagesettile() Set the tile image for filling the area.
imagestringup() It is used to draw a string vertically.
imagesx() Return the width of the given image.
imagesy() Return the height of the given image.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!