The imagegd() function is an inbuilt function in PHP which is used to output GD image to browser or file. This is most useful to convert any other image type to gd. imagecreatefromgd() function can be used to further read gd images.
bool imagegd( resource $image, float $to)
Parameters:This function accepts two parameters as mentioned above and described below:
- $image: It specifies the imag to be worked upon.
- $to (Optional): It specifies the path to save the file to.
Return Value: This function returns TRUE on success or FALSE on failure.
Exceptions: This function throws Exception on error.
Below given programs illustrate the imagegd() function in PHP:
Program 1 (Viewing a GD file):
This will output the image in the form of string as gd isn't supported in browser.
Program 2 (Convert images into gd):
This will save a image with name geeksforgeeks.gd in the same folder.