Image Drawing Functions in GD Library
Following are some useful functions available in GD Library for creating and manipulating images in PHP.
Image Creation and Destruction Function
| Function |
Purpose |
| imagecreate () |
It is used to create palette based image using GD. |
| imagecreatetruecolor () |
It is used to create true color based image using GD. |
| imagecreatefromjpeg () |
It is used to create new image from jpeg image file using GD. |
| imagedestroy () |
It is used to free all the resources used by the image. |
Color Allocation and De allocation Function
| Function |
Purpose |
| imagecolorallocate () |
This function is used to allocate color in RGB format to the image. |
| imagecolordeallocate () |
This function is used to de allocate the color that is allocated to the image previously using imagecolorallocate () function. |
Drawing Functions
| Function |
Purpose |
| imageline () |
This function is used to draw a line. |
| imagedashedline () |
This function is used to draw a dashed line. |
| imagerectangle () |
This function is used to draw a rectangle. |
| imagepolygon () |
This function is used to draw a polygon. |
| imageellipse () |
This function is used to draw an ellipse. |
| imagearc () |
This function is used to draw an arc. |
Drawing and Filling Function
| Function |
Purpose |
| imagefilledrectangle () |
This function is used to draw a rectangle that is filled with specific color. |
| imagefilledpolygon () |
This function is used to draw a polygon that is filled with specific color. |
| imagefilledellipse () |
This function is used to draw an ellipse that is filled with specific color. |
| imagefill () |
This function is used to fill an image with specific color. |
Text Function
| Function |
Purpose |
| imagestring () |
This function is used to display or output some text on the image. |
Export Function
| Function |
Purpose |
| imagepng () |
This function converts the internal GD image to png image format. |
| imagejpeg () |
This function converts the internal GD image to jpeg image format. |
| imagegif () |
This function converts the internal GD image to GIF image format. |
Height and Width Function
| Function |
Purpose |
| imagesx () |
This function returns the width of an image. |
| imagesy () |
This function returns the height of an image. |
Download Projects
Download Programs