I couldn't find any usefull documentation on DrawableFilterConfig methods. I googled some more found this thread on gimpchat.com GIMP 3 now has GEGL automation in python console. So to set parameters for filters you do this:
To print the parameters in the console you can use DrawableFilter.get_config().list_properties():
Now let's add Gaussian Blur
I tried to add all properties for Gaussian Blur at once but
and
didn't work either. To merge the filters down use:
How do you find out what the filter operation’s name are like 'gimp:threshold-alpha' and 'gegl:gaussian-blur' when using Gimp.DrawableFilter.new(drawable, operation_name, name)?
Code:
# Get image and selected layer.
image = Gimp.get_images()[0]
layer = image.get_selected_layers()[0]
# Add Threshold Alpha layer fx (Layer > Transparency > Threshold Alpha...).
filter_threshold_alpha = Gimp.DrawableFilter.new(layer, 'gimp:threshold-alpha', 'My Threshold Alpha')
Code:
for parameter in filter_threshold_alpha.get_config().list_properties():
parameter.get_name(), parameter.get_default_value()
# To set the parameter to 0 you do
filter_threshold_alpha.get_config().set_property('value', 0.0)
# Append Threshold Alpha filter to the layer.
layer.append_filter(filter_threshold_alpha)
Code:
# Add Gaussian Blur layer fx (Filters > Blur > Gaussian Blur...).
filter_gaussian_blur = Gimp.DrawableFilter.new(layer, 'gegl:gaussian-blur', 'My Gaussian Blur')
# set properties for Gaussian Blur.
filter_gaussian_blur.get_config().set_property('std-dev-x', 5.5)
filter_gaussian_blur.get_config().set_property('std-dev-y', 5.5)
# If you set the properties after adding the filter to the layer you have to use:
filter_gaussian_blur.update()
Code:
filter_gaussian_blur.get_config().set_properties(('std-dev-x', 1.5), ('std-dev-y', 1.5), ('filter', 'auto'), ('abyss-policy', 'clamp'), ('clip-extent', True))
Code:
filter_gaussian_blur.get_config().set_properties(5.5, 5.5, 'auto', 'clamp', True)
Code:
layer.merge_filters()
How do you find out what the filter operation’s name are like 'gimp:threshold-alpha' and 'gegl:gaussian-blur' when using Gimp.DrawableFilter.new(drawable, operation_name, name)?