Laravel PHP

How to rotate image and save in php

How to rotate image and save in php

One of the reader requested to explain about rotate the image and save using php. We are calling rotated image as Exif images.
PHP have library function to rotate an image, imagerotate is the php function which is used to rotate the image in php.
imagejpeg function will save the rotated image to your folder.



Create a new image from file or URL.


Rotates the image image using the given angle in degrees.
The center of rotation is the center of the image, and the rotated image may have different dimensions than the original image.


imagejpeg() creates a JPEG file from the given image.
bool imagejpeg ( resource $image [, string $filename [, int $quality ]] )

An image resource, returned by one of the image creation functions, such as imagecreatetruecolor().

The path to save the file to. If not set or NULL, the raw image stream will be outputted directly.

To skip this argument in order to provide the quality parameter, use NULL.

quality is optional, and ranges from 0 (worst quality, smaller file) to 100 (best quality, biggest file). The default is the default IJG quality value (about 75).

If you like this article please dont’t forget to share and comment.