imagerotate

(PHP 4 >= 4.3.0, PHP 5)

imagerotate -- 用給定角度旋轉圖像

說明

resource imagerotate ( resource src_im, float angle, int bgd_color [, int ignore_transparent] )

src_im 圖像用給定的 angle 角度旋轉。bgd_color 指定了旋轉後沒有覆蓋到的部分的彩色。

旋轉的中心是圖像的中心,旋轉後的圖像會按比例拉遠以適合目的圖像的大小--邊緣不會被剪去。

若果 ignore_transparent 被設為非零值,則透明色會被忽略(否則會被保留)。此參數是 PHP 5.1 新加的。

例子 1. 將圖像旋轉 180 度

本例將把一幅圖像旋轉 180 度--上下顛倒。

// 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);

注: 本函數僅在 PHP 與其捆綁的 GD 庫一起編譯時可用。