Calling Filter dialog in Python Script

I’m using krita mainly to edit photos. Switched over from gimp about two years ago.

I want to write some python scripts to automate (and speed up) things i do very often and include several single steps.
For example frequency separation i always do the following steps (by hand at the moment):
duplicate layer, blur it, set blend to grain extract, select all, copy merged, paste, deselect, add a group layer, move layers into that group layer, set blurred layer to normal, set pasted layer to grain merge

As you can see it includes to call gaussian blur, but i have to change the settings sligthly depending on the picture. I would like to automate that process and therefor i need to know how to call an existing filter dialog. The tutorial series for python plugins was a good starting point, but that topic was not covered unfortunately. There was just an example how to apply a filter that has no settings at all.

So how can i call an already existing filter dialog (especially gaussian blur in my case) to change and preview the settings and apply it in a python plugin?

1 Like

Hi

I took a look about your question and didn’t find a solution.
Tried to see if Krita.instance().setBatchmode() and Krita.instance().activeDocument().setBatchmode() changed something but no…

Maybe I’m wrong but from a python script, it seems that filter parameters can only be changed through and InfoObject() initialised with the right properties.

In this case if you only have one filter (and especially gaussian blur for which parameters interface is simple) for which you need to made some manual tuning, currently the only one solution I see is to create your own Qt dialog interface (not really difficult but need some development competences)

Grum999

if it is just filters it should be this.

from krita import *

print(Krita.instance().filters())

==== Warning: Script not saved! ====
[‘asc-cdl’,
‘autocontrast’,
‘blur’,
‘burn’,
‘colorbalance’,
‘colortoalpha’,
‘colortransfer’,
‘crosschannel’,
‘desaturate’,
‘dodge’,
‘edge detection’,
‘emboss’,
‘emboss all directions’,
‘emboss horizontal and vertical’,
‘emboss horizontal only’,
‘emboss laplascian’,
‘emboss vertical only’,
‘gaussian blur’,
‘gaussiannoisereducer’,
‘gradientmap’,
‘halftone’,
‘height to normal’,
‘hsvadjustment’,
‘indexcolors’,
‘invert’,
‘lens blur’,
‘levels’,
‘maximize’,
‘mean removal’,
‘minimize’,
‘motion blur’,
‘noise’,
‘normalize’,
‘oilpaint’,
‘perchannel’,
‘phongbumpmap’,
‘pixelize’,
‘posterize’,
‘raindrops’,
‘randompick’,
‘roundcorners’,
‘sharpen’,
‘smalltiles’,
‘threshold’,
‘unsharp’,
‘wave’,
‘waveletnoisereducer’]

I must warn that some filters through python act a bit weird, and they know about it I think. But I don’t know how it stands at the moment.

Thx for your effort. Well, the python scripting possibilities are quite new to krita, isn’t it? I hope calling existing dialogs and even more important documentation will get better in future.

I am not so sure about that … :frowning:

I didn’t tried, but executing a filter from action should display dialog box I think, because I think it emulate click on menu… But need to be confirmed…

Grum999

1 Like

Seeing here on KA how many people use and want to use Python plugins definitely made it seem much more important than it was before, when the only way to see that something is being developed is monitoring the Resources page…

1 Like