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: