當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python Wand rotate()用法及代碼示例

旋轉會改變圖像的方向或將圖像旋轉到特定角度。 rotae()的程度可以為0到359。(實際上,您可以傳遞360、361或更多,但分別等於0、1或更多。)

用法:
wand.image.rotatae(degree, background, reset_coords)

參數:

參數 輸入類型 描述
degree numbers.Real 旋轉的角度。 360的倍數沒有影響
background wand.color.Color 可選的背景色。默認是透明的。
reset_coords bool 可選標誌。如果設置,則旋轉後,坐標係將重定位到新圖像的左上角。默認情況下為True。

源圖像:

範例1:



# Import Image from wand.image module 
from wand.image import Image 
  
with Image(filename ="koala.jpeg") as img:
    with img.clone() as rotated:
        # rotate image using rotate() function 
        rotated.rotate(90) 
        rotated.save(filename ='transform-rotated-90.jpg')

輸出:

範例2:

# Import Image from wand.image module 
from wand.image import Image 
from wand.color import Color 
  
with Image(filename ="koala.jpeg") as img:
    with img.clone() as rotated:
        # rotate image using rotate() function 
        rotated.rotate(135, background = Color('rgb(229, 221, 112)')) 
        rotated.save(filename ='transform-rotated-135.jpg')

輸出:




相關用法


注:本文由純淨天空篩選整理自RahulSabharwal大神的英文原創作品 Wand rotate() function in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。