PHP | imagecreatefromgd() function Last Updated : 30 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The imagecreatefromgd() function is an inbuilt function in PHP which is used to create a new image from GD file or URL. Further, this image can be worked upon in the program. An image can be converted into GD format using the imagegd() function. Syntax: resource imagecreatefromgd( string $filename ) Parameters:This function accepts a single parameter $filename which holds the name or URL of file. Return Value: This function returns an image resource identifier on success, FALSE on errors. Below given programs illustrate the imagecreatefromgd() function in PHP: Program 1 (Viewing a gd file in browser): php <?php // Load the GD image from localfile $im = imagecreatefromgd('geeksforgeeks.gd'); // Output the image to browser imagegd($im); imagedestroy($im); ?> Output: This will load gd image in text form as it is not supported by browser. Program 2 (Converting GD into png and viewing in browser): php <?php // As GD isn't supported in browser, it can be // converted into PNG to be viewed in browser // Load the GD image $im = imagecreatefromgd('geeksforgeeks.gd'); // Output the image to browser header("Content-Type: image/png"); imagepng($im); imagedestroy($im); ?> Output: Program 3 (Converting GD into jpg): php <?php // Load the GD image $im = imagecreatefromgd('geeksforgeeks.gd'); // Convert the image and save in local folder imagejpeg($im, 'geeksforgeeks.jpg'); imagedestroy($im); ?> Output: This will convert GD image into JPEG and save in local folder. Reference: https://www.php.net/manual/en/function.imagecreatefromgd.php Comment More infoAdvertise with us Next Article PHP | imagecreatefromgd() function gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | imagecreatefromgd2() function The imagecreatefromgd2() function is an inbuilt function in PHP which is used to create a new image from file or URL. Further, this image can be worked upon in the program. Usually, gd2 extension is not supported in the browser thus it can be used to convert it into png and view it in the browser.Sy 1 min read PHP | imagecreatefrompng() Function The imagecreatefrompng() function is an inbuilt function in PHP which is used to create a new image from PNG file or URL. This image can be further worked upon in the program. This function is usually used when you want to edit your PNG images. Syntax: resource imagecreatefrompng( string $filename ) 1 min read PHP | imagecreatefromgif() Function The imagecreatefromgif() function is an inbuilt function in PHP which is used to create a new image from a given part of GIF file or URL. Further, this image can be worked upon in the program. This function only loads the first frame of the animation. Syntax: resource imagecreatefromgif( string $fil 1 min read PHP | imagecreatefromjpeg() Function The imagecreatefromjpeg() function is an inbuilt function in PHP which is used to create a new image from JPEG file or URL. This image can be further worked upon in the program. Syntax: resource imagecreatefromjpeg( string $filename ) Parameters: This function accepts a single parameter, $filename w 1 min read PHP | imagecreatefromgd2part() Function The imagecreatefromgd2part() function is an inbuilt function in PHP which is used to create a new image from a given part of GD2 file or URL. Further, this image can be worked upon in the program. Usually, gd2 extension is not supported in the browser thus it can be used to convert it into png and v 2 min read PHP | imagecreatefromxbm() function The imagecreatefromxbm() function is an inbuilt function in PHP which is used to create a new image from XBM file or URL. XBM file extension is an X Bitmap Graphics file used for Graphical UI systems. This loaded image can be further worked upon in the program. This function is usually used when you 2 min read PHP | imagecreatefrombmp() Function The imagecreatefrombmp() function is an inbuilt function in PHP which is used to create a new image from file or URL. Syntax: resource imagecreatefrombmp( string $filename ) Parameters: This function accepts a single parameter $filename which holds the name or URL of a file. Return Value: This funct 1 min read PHP | imagecreatefromxpm() Function The imagecreatefromxpm() function is an inbuilt function in PHP which is used to create a new image from XPM file or URL. XPM (X PixMap) is an image file format used by the X Window System. This loaded image can be further worked upon in the program. This function is usually used when you want to ed 2 min read PHP | imagecreatefromstring() Function The imagecreatefromstring() function is an inbuilt function in PHP which is used to create a new image from string file or URL. This image can be further worked upon in the program. This function is usually used when you want to edit your images after loading them from a string. Syntax: resource ima 2 min read PHP | imagecreatefromwbmp() Function The imagecreatefromwbmp() function is an inbuilt function in PHP which is used to create a new image from WBMP file or URL. WBMP (Wireless Application Protocol Bitmap Format) is a monochrome graphics file format optimized for mobile computing devices. This loaded image can be further worked upon in 2 min read Like