📜  Python中的魔杖matte_color属性

📅  最后修改于: 2022-05-13 01:55:46.445000             🧑  作者: Mango

Python中的魔杖matte_color属性

一些失真过渡无法在虚拟像素空间中计算。要么无效,要么 NaN(非数字)。您可以通过设置 Image.matte_color 属性来定义如何表示这样的像素。

句法 :

wand.image.matte_color = 'color'

源图像:

示例 1:
from wand.color import Color
# Import Image from wand.image module
from wand.image import Image
   
# Read image using Image function
with Image(filename ="gog.png") as img:
    img.matte_color = Color('BLUE')
    img.virtual_pixel = 'tile'  
    args = (0, 0, 30, 60, 140, 0, 110, 60,
            0, 92, 2, 90, 140, 92, 138, 90)
    img.distort('perspective', args)
    img.save(filename ="rdmc.jpg")

输出 :

示例 2:
将 VIRTUAL_PIXEL_METHOD 更改为平铺

from wand.color import Color
# Import Image from wand.image module
from wand.image import Image
   
# Read image using Image function
with Image(filename ="gog.png") as img:
    arguments = (0, 0, 20, 60,
                 90, 0, 70, 63,
                 0, 90, 5, 83,
                 90, 90, 85, 88)
    img.matte_color = Color('YELLOW')
    img.distort('perspective', arguments)
    img.save(filename ='mattegog.png')

输出 :