![]() |
How to work with effects in GIMP Python? - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: How to work with effects in GIMP Python? (/Thread-How-to-work-with-effects-in-GIMP-Python) |
How to work with effects in GIMP Python? - joeyeroq - 04-02-2025 In GIMP 2 you could threshold the alpha channel (Layer > Transparency > Threshold Alpha...), in Python console equivalent was: Code: image = gimp.image_list()[0] In GIMP 3 Threshold Alpha has become a filter ("fx" icon next to the layer) I can do in GIMP 3: Code: image = Gimp.get_images()[0] How do I change the settings of the filters, for example how do i set the alpha value to 0 of 'My Threshold Alpha'? [attachment=13334] RE: How to work with effects in GIMP Python? - joeyeroq - 04-02-2025 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: Code: # Get image and selected layer. Code: for parameter in filter_threshold_alpha.get_config().list_properties(): Code: # Add Gaussian Blur layer fx (Filters > Blur > Gaussian Blur...). 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)? RE: How to work with effects in GIMP Python? - Ofnuts - 04-03-2025 Some pointers (no time to develop more that this ATM):
RE: How to work with effects in GIMP Python? - joeyeroq - 04-06-2025 Thanks to HoneyBadger at GIMP Discord: HoneyBadger wrote 2025-04-05T06:28:14.224Z about getting the name of operations like 'gimp:threshold-alpha' and 'gegl:gaussian-blur': You can extract the names of operations from the filters applied to the layer: Code: Gimp.get_images()[0].get_layers()[0].get_filters()[0].get_operation_name() HoneyBadger wrote 2025-04-04T21:04:43.798Z about adding all properties of a filter at once in stead of one by one: It turns out the documentation is not complete, the method really exists You can use it like this: Code: config.set_properties(prop1=value1, prop2=value2) But if the property name contains a hyphen, you will have to do it differently: Code: my_props = { Or: Code: config.set_properties(**{ 'std-dev-y': 3, 'std-dev-x': 3 }) You can even mix them together if you want: Code: config.set_properties(filter='auto', **{ 'std-dev-y': 3, 'std-dev-x': 3 }) RE: How to work with effects in GIMP Python? - Ofnuts - 04-06-2025 In practice for a similar call I use a wrapper: Code: def callProcedure(procId: str, run_mode=Gimp.RunMode.NONINTERACTIVE, **kwargs): So you can call the procedure with Python keyword arguments: Code: res = callProcedure('plug-in-sel2path', image=image, |