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


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

tint()函數通過混合給定的顏色來使圖像的中間色調著色。 alpha參數控製顏色通道之間的混合效果。但是,使用它可能很棘手,因此在有疑問時,請使用alpha =” gray(50)”參數。

用法:
wand.image.tint(color, alpha)

參數:

參數 輸入類型 描述
color Color 顏色以計算中間調。
alpha Color 確定如何混合。

源圖像:

範例1:



# Import Image from wand.image module 
from wand.image import Image 
  
# Read image using Image function 
with Image(filename ="koala.jpeg") as img:
  
    # tinted image using tint() function 
    img.tint(color ="yellow", alpha ="rgb(40 %, 60 %, 80 %)") 
    img.save(filename ="tintkoala.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:
  
    # implode imagefx using implode() function 
    img.tint(color ="green", alpha ="rgb(10 %, 20 %, 40 %)") 
    img.save(filename ="tint2.jpeg")

輸出:




相關用法


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