📜  魔杖 virtual_pixel 属性 - Python

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

魔杖 virtual_pixel 属性 - Python

在对光栅图像执行失真时,生成的图像通常包含原始边界光栅之外的像素。这些区域称为垂直像素,可以通过将 Image.virtual_pixel 设置为VIRTUAL_PIXEL_METHOD中定义的任何值来控制。
以下是 VIRTUAL_PIXEL_METHOD :

VIRTUAL_PIXEL_METHODDescription
‘undefinedstandard default VIRTUAL_PIXEL_METHOD.
‘backgroundset virtual pixel solid background.
‘dither’dither creates dotted edges around the distort edges.
‘edge’distinct edges
‘mirror’a mirror pixel is plotted on Virtual pixels and give a mirror effect
‘random’random pixels from image are plotted.
’tile’a tile effect is created.
‘transparent’sets virtual pixels transparent.
‘mask’set virtual pixels blank and create mask effect.
‘black’sets virtual pixels of black color.
‘gray’sets virtual pixels of gray color.
‘white’sets virtual pixels of white color.
‘horizontal_tile’set tile effect horizontally only.
‘vertical_tile’set tile effect vertically only.
‘horizontal_tile_edge’set tile effect horizontally only with distinct edges.
‘vertical_tile_edge’set tile effect vertically only with distinct edges.
‘checker_tile’Create check effect

句法 :

wand.image.virtual_pexel = 'VIRTUAL_PIXEL_METHOD'

源图像:

示例 1:

Python3
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",  background = Color("green")) as img:
 
    img.virtual_pixel = 'checker_tile'
    img.distort('arc', (60, ))
    img.save(filename ='rdsv.jpg')


Python3
# Import Image from wand.image module
from wand.image import Image
  
# Read image using Image function
with Image(filename ="rd.jpg") as img:
    img.virtual_pixel = 'tile'
    img.distort('arc', (60, ))
    img.save(filename ='rdsv2.jpg')


输出:

示例 1:
将 VIRTUAL_PIXEL_METHOD 更改为平铺

Python3

# Import Image from wand.image module
from wand.image import Image
  
# Read image using Image function
with Image(filename ="rd.jpg") as img:
    img.virtual_pixel = 'tile'
    img.distort('arc', (60, ))
    img.save(filename ='rdsv2.jpg')

输出 :