PHP | imagefilledrectangle() Function Last Updated : 23 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The imagefilledrectangle() function is an inbuilt function in PHP which is used to create a filled rectangle. This function creates a rectangle filled with a given color in the image. The top left corner of the image is (0, 0). Syntax: bool imagefilledrectangle( $image, $x1, $y1, $x2, $y2, $color ) Parameters: This function accepts six parameters as mentioned above and described below: $image: It is returned by one of the image creation functions, such as imagecreatetruecolor(). It is used to create size of image. $x1: This parameter is used to set the x-coordinate for point 1. $y1: This parameter is used to set the y-coordinate for point 1. $x2: This parameter is used to set the x-coordinate for point 2. $y2: This parameter is used to set the y-coordinate for point 2. $color: This parameter contains the filled color identifier. A color identifier created with imagecolorallocate() function. Return Value: This function returns True on success or False on failure. Below programs illustrate the imagefilledrectangle() function in PHP: Program 1: php <?php // Create an image of given size $image = imagecreatetruecolor(500, 300); $green = imagecolorallocate($image, 0, 153, 0); // Draw the rectangle of green color imagefilledrectangle($image, 20, 20, 480, 280, $green); // Output image in png format header("Content-type: image/png"); imagepng($image); // Free memory imagedestroy($image); ?> Output: Program 2: php <?php // Create an image of given size $image = imagecreatetruecolor(500, 300); $white = imagecolorallocate($image, 255, 255, 255); // Draw the rectangle of white color imagefilledrectangle($image, 20, 20, 480, 280, $white); // Output image header("Content-type: image/png"); imagepng($image); // Free memory imagedestroy($image); ?> Output: Related Articles: PHP | imagepolygon() Function PHP | imagefilledellipse() Function PHP | imagecolorallocate() Function Reference: http://php.net/manual/en/function.imagefilledrectangle.php Comment More infoAdvertise with us Next Article PHP | imagefilledrectangle() Function V vijay_raj Follow Improve Article Tags : Misc Web Technologies PHP Image-Processing PHP-function +1 More Practice Tags : Misc Similar Reads PHP | imagerectangle() Function The imagerectangle() function is an inbuilt function in PHP which is used to draw the rectangle. Syntax: bool imagerectangle( $image, $x1, $y1, $x2, $y2, $color ) Parameters: This function accepts six parameters as mentioned above and described below: $image: It is returned by one of the image creat 2 min read PHP | imagefilledarc() Function The imagefilledarc() function is an inbuilt function in PHP which is used to draws a partial arc centered at the specified coordinate in the given image. This function return True on success or False on failure Syntax: bool imagefilledarc ( $image, $cx, $cy, $width, $height, $start, $end, $color, $s 2 min read PHP | imagefill() Function The imagefill() function is an inbuilt function in PHP which is used to fill the image with the given color. This function performs a flood fill starting at the given coordinate (top left is 0, 0) with the given color in the image. Syntax: bool imagefill( $image, $x, $y, $color ) Parameters:This fun 2 min read PHP | imagefilledpolygon() Function The imagefilledpolygon() function is an inbuilt function in PHP which is used to draw a filled polygon. This function Returns TRUE on success and returns FALSE otherwise. Syntax:Â bool imagefilledpolygon( $image, $points, $num_points, $color ) Parameters: This function accepts four parameters as men 2 min read PHP | imagecreate() Function The imagecreate() function is an inbuilt function in PHP which is used to create a new image. This function returns the blank image of given size. In general imagecreatetruecolor() function is used instead of imagecreate() function because imagecreatetruecolor() function creates high quality images. 2 min read Like