PHP | imagecreatefromgd2part() Function Last Updated : 14 Feb, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 view it in the browser. Syntax: resource imagecreatefromgdpart( string $filename, int $srcX, int $srcY, int $width, int $height ) Parameters: This function accept five parameters as mentioned above and described below: $filename: It specifies the GD2 image. $srcX: It specifies the x-coordinate of source point. $srcY: It specifies the y-coordinate of source point. $width: It specifies the width of image. $height: It specifies the height of image. Return Value: This function returns an image resource identifier on success, FALSE on errors. Below given programs illustrate the imagecreatefromgd2part() function in PHP: Program 1 (Viewing a gd2 file in browser): php <?php // Load the GD2 image from local folder GD2 images // can be created with imagegd2() function $im = imagecreatefromgd2part('./geeksforgeeks.gd2', 300, 0, 300, 300); // Convert to PNG and output to the browser header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> Output: Program 2 (Converting gd2 into jpeg): php <?php // Load the GD2 image from local folder GD2 images // can be created with imagegd2() function $im = imagecreatefromgd2part('./geeksforgeeks.gd2', 30, 0, 100, 250); // Convert to JPEG and save to local folder imagejpeg($im, 'newgeeksforgeeks.jpeg'); imagedestroy($im); ?> Output: It will load the part of image and convert it into JPEG and saves it into same folder. Reference: https://www.php.net/manual/en/function.imagecreatefromgd2part.php Comment More infoAdvertise with us Next Article PHP | imagecreatefrombmp() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-image-functions 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 | imagecreatefromgd() function 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 ) 2 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 | 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 | 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 Like