Related Articles

Related Articles

Wand matte_color property in Python
  • Last Updated : 08 May, 2020

Some distortion transitions can not be calculated in the virtual-pixel space. Either being invalid, or NaN (not-a-number). You can define how such a pixel should be represented by setting the Image.matte_color property.

Syntax :

wand.image.matte_color = 'color'

Source Image:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :



Example 2:
changing VIRTUAL_PIXEL_METHOD to tile

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :