Python Scripting Filter Mask Updates Not Applying

I’m trying to update a filter layer with a python script to auto-generate different color variations. This sort of works; if I look at the filter properties, they do indeed show the new value, but I need to manually hide and show the layer in order for the change to actually be applied to the image. I’ve tried hiding the layer programmatically as well, but the same issue happens: the layer appears hidden in the toolbar, but the image doesn’t update until I change something else manually.
Is there a way to programmatically force the document/node/filter to re-render itself?
Here’s the unnecessarily verbose code I wrote trying to get this to work, and help would be appreciated!
K = Krita.instance()
d = K.activeDocument()
n = d.nodeByName(“HSV/HSL Adjustment”)
c = n.filter().configuration()
c.setProperty(“h”, 100)
n.filter().apply(n, 0, 0, d.width(), d.height())

it lookslike there is tiny bug in Document.nodeByName() return type.
here is a work around.

from krita import Krita, FilterLayer

def debug_node(node):
    it looks like there is something strange
    in python type of FilterLayer node?
    version = Krita.instance().version()
    name =
    kis_type = node.type()
    py_type = type(node).__name__
               "  version={version}"
               "  name={name!r},\n"
               "  kis_type={kis_type!r},\n"
               "  py_type={py_type}").format(**locals()))

def nodeByName(document, name):
    walk node tree in depth first order.
    return first node where matches name.
    stack = [document.rootNode()]
    while stack:
        node = stack.pop(-1)  # depth first
        if == name:
            return node

def my_color_variation():
    Find <node_name> filter from currently active document,
    and change filter configuration.
    app = Krita.instance()
    document = app.activeDocument()

    # node = document.nodeByName("HSV/HSL Adjustment")
    node = nodeByName(document, "HSV/HSL Adjustment")
    # debug_node(node)
    if isinstance(node, FilterLayer):
        filter = node.filter()
        config = filter.configuration()

        # modify filter configuration
        config.setProperty("h", 100)

        # use modified config in filter

        # force update document & wait until done


Ps. debug_node() is not needed, left here for developers.


After you make changes to a layer, you need to use the document.refreshProjection(). This will update the canvas so you can see your changes. This works for me…

K = Krita.instance()
d = K.activeDocument()
n = d.nodeByName(“HSV/HSL Adjustment”)
config = n.filter().configuration() # the c was turning into copyright symbol on this site
config.setProperty(“h”, 100)
n.filter().apply(n, 0, 0, d.width(), d.height())

Check out the python site if you want a bit more information with working with layers and filters.

Thanks a lot for the help, and especially for that website! I’ve been looking for something like that, but it never showed up in any of my searches.