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


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

wave()函數從圖像的頂部和底部創建波形結構。在圖像內產生波紋效果。我們可以使用wave()函數中的幅度和wave_length參數來更改圖像的波長和幅度。

用法:
wand.image.wave(amplitude, wave_legth)

參數:

參數 輸入類型 描述
amplitude numbers.Integer 設置波幅。
wavelength numbers.Integer 設置波的波長。

源圖像:

範例1:



# Import Image from wand.image module 
from wand.image import Image 
  
# Read image using Image function 
with Image(filename ="koala.jpeg") as img:
  
    # rippled image using vignette() function 
    img.wave(amplitude = img.height / 32, 
             wave_length = img.width / 4) 
    img.save(filename ="wkoala2.jpeg")

輸出:

範例2:增加幅度並減少波長。

# Import Image from wand.image module 
from wand.image import Image 
  
# Read image using Image function 
with Image(filename ="koala.jpeg") as img:
  
    # rippled image using vignette() function 
    img.wave(amplitude = img.height / 24, 
             wave_length = img.width / 8) 
    img.save(filename ="wkoala2.jpeg")

輸出:




相關用法


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