Wand virtual_pixel property – Python
Last Updated :
28 Feb, 2023
When performing distortion on raster images, the resulting image often includes pixels that are outside original bounding raster. These regions are referred to as vertical pixels, and can be controlled by setting Image.virtual_pixel to any value defined in VIRTUAL_PIXEL_METHOD.
Following are the VIRTUAL_PIXEL_METHOD :
VIRTUAL_PIXEL_METHOD |
Description |
‘undefined |
standard default VIRTUAL_PIXEL_METHOD. |
‘background |
set 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 |
Syntax :
wand.image.virtual_pixel = 'VIRTUAL_PIXEL_METHOD'
Source Image:
Example 1:
Python3
from wand.color import Color
from wand.image import Image
with Image(filename = "gog.png" , background = Color( "green" )) as img:
img.virtual_pixel = 'checker_tile'
img.distort( 'arc' , ( 60 , ))
img.save(filename = 'rdsv.jpg' )
|
Output:
Example 1:
changing VIRTUAL_PIXEL_METHOD to tile
Python3
from wand.image import Image
with Image(filename = "rd.jpg" ) as img:
img.virtual_pixel = 'tile'
img.distort( 'arc' , ( 60 , ))
img.save(filename = 'rdsv2.jpg' )
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...