Create a specific filter layer

Hi

Here an example for Hue/Saturation/Value adjustment layer:

from krita import *

# work on current document
activeDoc=Krita.instance().activeDocument()

# define filter properties
configParameters=InfoObject()
configParameters.setProperties({
        'colorize': False,
        'compatibilityMode': False,
        'type': 1,
        'h': 0,
        's': -30,
        'v': 25
    })
    
# create filter
filter=Filter()
filter.setName('hsvadjustment')
filter.setConfiguration(configParameters)

# define selection on which filter will be applied (here all document area)
selection=Selection()
selection.select(0,0,activeDoc.width(), activeDoc.height(), 255)

# create filter layer
filterLayer=activeDoc.createFilterLayer("New filter layer", filter, selection)

# add it to document
activeDoc.rootNode().addChildNode(filterLayer, None)

Note: for color adjustment and cross-channel layer, I’m not able to determinate how to provide parameter (even not sure that’s working)
Check topic: Scripting with Colour Adjustment filter layer

Grum999

2 Likes