Php rotating images 90 degrees

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff to enter the php rotating picture 90 degrees. The method is not difficult. Let's take a look at the function below: the code is as follows: [php] viewplaincopy *** modify an image to flip it to a specified degree ** @ paramstring $ filename file name (including file path) * @ paramf

Welcome to the Linux community forum and interact with 2 million technicians> go to php to rotate the image 90 degrees. The method is not difficult. Let's take a look at the function below: the code is as follows: [php] view plaincopy/*** modify an image to flip it to a specified degree ** @ param string $ filename file name (including file path) * @ param f

Welcome to the Linux community forum and interact with 2 million technicians>

Php rotating images 90 degrees, the method is not difficult. Let's take a look at the function below:

The Code is as follows:

[Php] view plaincopy

/**

* Modify an image to flip it to a specified degree

*

* @ Param string $ filename file name (including file path)

* @ Param float $ degrees rotation degree

* @ Return boolean

*/

Function flip ($ filename, $ src, $ degrees = 90)

{

// Read the image

$ Data = @ getimagesize ($ filename );

If ($ data = false) return false;

// Read the old image

Switch ($ data [2]) {

Case 1:

$ Src_f = imagecreatefromgif ($ filename); break;

Case 2:

$ Src_f = imagecreatefromjpeg ($ filename); break;

Case 3:

$ Src_f = imagecreatefrompng ($ filename); break;

}

If ($ src_f = "") return false;

$ Rotate = @ imagerotate ($ src_f, $ degrees, 0 );

If (! Imagejpeg ($ rotate, $ src, 100) return false;

@ Imagedestroy ($ rotate );

Return true;

}

The above is how php rotates images 90 degrees. I hope this article will be helpful to php developers. Thank you for reading this article.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.