PHP | GmagickDraw rectangle() Function Last Updated : 29 Jan, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The GmagickDraw::rectangle() function is an inbuilt function in PHP which is used to draw the rectangle. Syntax: public GmagickDraw::rectangle( $x1, $y1, $x2, $y2 ) Parameters:This function accepts four parameters as mentioned above and described below: $x1: This parameter takes the value of x coordinate of the top left corner. $y1: This parameter takes the value of y coordinate of the top left corner. $x2: This parameter takes the value of x coordinate of the bottom right. $y2: This parameter takes the value of y coordinate of the bottom right. Return Value: This function returns GmagickDraw object on success. Errors/Exceptions: This function throws GmagickException on error. Below programs illustrate the GmagickDraw::rectangle() function in PHP: Program 1: php <?php // Create a GmagickDraw object $draw = new GmagickDraw(); // Set the color $draw->setFillColor('Green'); // Set the width and height of image $draw->setStrokeWidth(7); $draw->setFontSize(72); // Function to draw rectangle $draw->rectangle(20, 20, 380, 465); $gmagick = new Gmagick(); $gmagick->newImage(500, 500, 'White'); $gmagick->setImageFormat("png"); // Use of drawimage function $gmagick->drawImage($draw); // Display the output image header("Content-Type: image/png"); echo $gmagick->getImageBlob(); ?> Output: Program 2: php <?php // Create a GmagickDraw object $draw = new GmagickDraw(); // Set the color $draw->setFillColor('Lightgreen'); // Set the width and height of image $draw->setStrokeWidth(7); $draw->setFontSize(72); // Function to draw rectangle $draw->rectangle(20, 20, 880, 465); $draw->setFontSize(40); $draw->setFillColor('Green'); $gmagick = new Gmagick(); $gmagick->newImage(900, 500, 'White'); $gmagick->setImageFormat("png"); // Use of drawimage function $gmagick->drawImage($draw); // Annotate Image $gmagick->annotateImage($draw, 5, 120, 0, ' GeeksforGeeks: A computer science portal'); $gmagick->annotateImage($draw, 5, 220, 0, ' sarthak_ishu11'); // Display the output image header("Content-Type: image/png"); echo $gmagick->getImageBlob(); ?> Output: Reference: http://php.net/manual/en/gmagickdraw.rectangle.php Comment More infoAdvertise with us Next Article PHP | GmagickDraw rectangle() Function S sarthak_ishu11 Follow Improve Article Tags : Web Technologies PHP Image-Processing PHP-function PHP-Gmagick +1 More Similar Reads PHP | ImagickDraw rectangle() Function The ImagickDraw::rectangle() function is an inbuilt function in Imagick library of PHP which is used to draw a rectangle. Syntax: bool ImagickDraw::rectangle( $x1, $y1, $x2, $y2 ) Parameters: This function accepts four parameters as mentioned above and described below: $x1: This parameter takes the 1 min read PHP | GmagickDraw roundrectangle() Function The GmagickDraw::roundrectangle() function is an inbuilt function in PHP which is used to draw a rounded rectangle. Syntax: public GmagickDraw::rectangle( $x1, $y1, $x2, $y2, $rx, $ry) Â Parameters:This function accepts four parameters as mentioned above and described below: $x1: This parameter take 2 min read PHP | ImagickDraw roundRectangle() Function The ImagickDraw::roundRectangle() function is an inbuilt function in Imagick library of PHP which is used to draw a rounded rectangle. Syntax: bool ImagickDraw::roundRectangle( $x1, $y1, $x2, $y2, $rx, $ry ) Parameters: This function accept six parameters as mentioned above and described below: $x1: 2 min read PHP | GmagickDraw rotate() Function The GmagickDraw::rotate() function is an inbuilt function in PHP which is used to apply the specified rotation to the current coordinate space. Syntax: GmagickDraw GmagickDraw::rotate( array $coordinates_array ) Parameters: This function accepts a single parameter $coordinates_array which is used to 2 min read PHP | ImagickDraw scale() Function The ImagickDraw::scale() function is an inbuilt function in PHP which is used to adjust the scaling factor to apply in the horizontal and vertical directions to the current coordinate space. Syntax:Â bool ImagickDraw::scale( $x, $y ) Parameters: This function accepts two parameter as mentioned above 2 min read Like