Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Wand virtual_pixel property – Python

  • Last Updated : 20 Apr, 2021

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_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

Syntax : 
 

wand.image.virtual_pexel = 'VIRTUAL_PIXEL_METHOD'

Source Image: 
 

Example 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')

Output: 
 

Example 1: 
changing VIRTUAL_PIXEL_METHOD to tile 
 

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')

Output : 
 

 




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!