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 info G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like