Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Wand fx() function – Python

  • Last Updated : 08 May, 2020

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 :

ParameterInput TypeDescription
expressionbasestringThe entire FX expression to apply.
channelCHANNELSOptional 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:




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!