PHP | imagerotate() Function Last Updated : 25 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The imagerotate() function is an inbuilt function in PHP which is used to rotate an image with a given angle in degrees. The rotation center of the image is center. Syntax: resource imagerotate( $image, $angle, $bgd_color, $ignore_transparent = 0 ) Parameters: This function accepts four 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. $angle: This parameter holds the rotation angle in degrees. The rotation angle is used to rotate an image in anticlockwise direction. $bgd_color: This parameter holds the background color of uncovered zone after rotation. $ignore_transparent: If this parameter set and non-zero then transparent colors are ignored. Return Value: This function returns an image resource for the rotated image on success, or False on failure. Below programs illustrate the imagerotate() function in PHP: Program 1: php <?php // Assign image file to variable $image_name = 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-15.png'; // Load image file $image = imagecreatefrompng($image_name); // Use imagerotate() function to rotate the image $img = imagerotate($image, 180, 0); // Output image in the browser header("Content-type: image/png"); imagepng($img); ?> Output: Program 2: php <?php // It create the size of image or blank image. $image = imagecreatetruecolor(500, 300); // Set the background color of image. $bg = imagecolorallocate($image, 205, 220, 200); // Fill background with above selected color. imagefill($image, 0, 0, $bg); // Set the color of an ellipse. $col_ellipse = imagecolorallocate($image, 0, 102, 0); // Function to draw the filled ellipse. imagefilledellipse($image, 250, 150, 400, 250, $col_ellipse); // Use imagerotate() function to rotate the image $img = imagerotate($image, 90, 0); // Output image in the browser header("Content-type: image/png"); imagepng($img); ?> Output: Reference: https://www.php.net/manual/en/function.imagerotate.php Comment More infoAdvertise with us Next Article PHP | imagerotate() Function J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads 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 PHP | imagecropauto() Function The imagecropauto() function is an inbuilt function in PHP which is used to crop an image automatically using one of the available modes. Syntax: resource imagecropauto( resource $image, int $mode, float $threshold, int $color ) Parameters: This function accepts four parameters as mentioned above an 2 min read PHP | imagecrop() Function The imagecrop() function is an inbuilt function in PHP which is used to crop an image to the given rectangle. This function crops an image to the given rectangular area and returns the resulting image. The given image is not modified. Syntax: resource imagecrop ( $image, $rect ) Parameters: This fun 1 min read PHP | imagesettile() Function The imagesettile() function is an inbuilt function in PHP which is used to set the tile image for filling the area. Syntax: bool imagesettile( $image, $tile ) Parameters: This function accepts two parameters as mentioned above and described below: $image: It is returned by one of the image creation 2 min read 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 Like