search
Homephp教程php手册php旋转图片90度的实例分享

php旋转图片90度的实例分享

Jun 06, 2016 pm 07:46 PM
phpsharepictureExamplerotateEnter

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 如何用php将图片旋转90度呢?本文分享一例php代码,使用php gd库实现图片的旋转,有兴趣的朋友可以参考研究下。 本节内容: php旋转图片90度 代码: 代码示例: ?php /** * 修改一个图片 让其翻转指

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  如何用php将图片旋转90度呢?本文分享一例php代码,使用php gd库实现图片的旋转,有兴趣的朋友可以参考研究下。

  本节内容:

  php旋转图片90度

  代码:

  代码示例:

  

  /**

  * 修改一个图片 让其翻转指定度数

  *

  * @param string  $filename 文件名(包括文件路径)

  * @param  float $degrees 旋转度数

  * @return boolean

  * @site

  */

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

  {

  //读取图片

  $data = @getimagesize($filename);

  if($data==false)return false;

  //读取旧图片

  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;

  }

php旋转图片90度的实例分享

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)