首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

imagerotate

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

imagerotate - 以给定的角度旋转图像

描述

代码语言:javascript
复制
resource imagerotate ( resource $image , float $angle , int $bgd_color [, int $ignore_transparent = 0 ] )

image使用给定angle度数旋转图像。

旋转的中心是图像的中心,并且旋转的图像可能具有与原始图像不同的尺寸。

参数

代码语言:txt
复制
`image`   

一个图像资源,由图像创建函数之一返回,如imagecreatetruecolor()。

angle

旋转角度,以度为单位。旋转角度被解释为用于逆时针旋转图像的度数。

bgd_color

指定旋转后未覆盖区域的颜色

ignore_transparent

如果设置为非零,则会忽略透明颜色(否则保留)。

返回值

返回旋转图像的图像资源,或者FALSE失败。

更新日志

描述

5.5.0

ignore_transparent现在被默默地忽略。

5.5.0

此功能现在受到imagesetinterpolation()函数设置的插值方法的影响。

5.1.0

ignore_transparent已添加。

例子

Example #1 Rotate an image 180 degrees

本示例将图像旋转180度 - 颠倒。

代码语言:javascript
复制
<?php
// File and rotation
$filename = 'test.jpg';
$degrees = 180;

// Content type
header('Content-type: image/jpeg');

// Load
$source = imagecreatefromjpeg($filename);

// Rotate
$rotate = imagerotate($source, $degrees, 0);

// Output
imagejpeg($rotate);

// Free the memory
imagedestroy($source);
imagedestroy($rotate);
?>

上面的例子会输出类似于:

Notes

注意:该功能受到imagesetinterpolation()设置的插值方法的影响。

← imageresolution

imagesavealpha →

扫码关注腾讯云开发者

领取腾讯云代金券