HomeLanguagesWand fx() function – Python

Wand fx() function – Python

FX special effects are a powerful “micro” language to work with. Simple functions & operators offer a unique way to access & manipulate image data. The fx() method applies a FX expression, and generates a new Image instance.

We can create a custom DIY filter that will turn the image black & white, except colors with a hue above 324°, or below 36°.

Syntax :

wand.image.fx(fx_string)

Parameters :

Parameter Input Type Description
expression basestring The entire FX expression to apply.
channel CHANNELS Optional channel to target.

Source Image:

Example 1:




# import IMage from wand.image module
from wand.image import Image
  
# expression string for fx()
fx_filter ="(hue > 0.9 || hue < 0.1) ? u : lightness"
  
with Image(filename ="koala.jpeg") as img:
    with img.fx(fx_filter) as filtered_img:
       filtered_img.save(filename ="fx-koala.jpeg")


Output:

Example 2:




# import IMage from wand.image module
from wand.image import Image
  
# expression string for fx()
fx_filter ="(luma > 0.9 || luma < 0.1) ? u : lightness"
  
with Image(filename ="koala.jpeg") as img:
    with img.fx(fx_filter) as filtered_img:
       filtered_img.save(filename ="fx-koala.jpeg")


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS