(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
imagerotate — 用給定角度旋轉圖像
$image
,$angle
,$bgd_color
,$ignore_transparent
= 0
將 src_im
圖像用給定的
angle
角度旋轉。bgd_color
指定了旋轉后沒(méi)有覆蓋到的部分的顏色。
旋轉的中心是圖像的中心,旋轉后的圖像會(huì )按比例縮小以適合目標圖像的大小——邊緣不會(huì )被剪去。
image
由圖象創(chuàng )建函數(例如imagecreatetruecolor())返回的 GdImage 對象。
angle
Rotation angle, in degrees. The rotation angle is interpreted as the number of degrees to rotate the image anticlockwise.
bgd_color
Specifies the color of the uncovered zone after the rotation
ignore_transparent
如果被設為非零值,則透明色會(huì )被忽略(否則會(huì )被保留)。
返回旋轉后的圖像資源,
或者在失敗時(shí)返回 false
。
版本 | 說(shuō)明 |
---|---|
5.1.0 |
新增: ignore_transparent 。
|
示例 #1 將圖像旋轉 180 度
本例將把一幅圖像旋轉 180 度——上下顛倒。
<?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);
?>
以上例程的輸出類(lèi)似于: