Python - Where are Gradient Map presets?

I can’t seem to find a way to select a Gradient Map preset by name from Python. I have looked in all the resource types in instance.resources() and didn’t see my presets. I assumed at least the currently selected preset would be returned in a call to instance.filter(‘gradientmap’).configuration().properties() but I get defaults (below). My app is configuration-driven and I have all my stops in presets, so I would strongly prefer retrieving the settings by name rather than manually adding all the presets from a config file.


'colorMode': False, 
'dither/noiseSeed': 635723058, 
'dither/pattern': 'DITH 0202 GEN ', 
'dither/patternValueMode': 0, 
'dither/spread': 1.0, 
'dither/thresholdMode': 0, 
'gradientXML': '<gradient type="stop"/>\n'


The gradient map presets are just gradients, so you should be able to access it by finding the gradient preset.

Thanks for the reply, tiar. Yea. that’s what I would expect too but when inspecting the output from instance.resources(‘gradient’) as well as instance.filters(), they appear in neither. I am sure there is something I am missing here.
I would expect to be able to load the ‘gradientmap’ filter:
then tell Krtia to initialize it with a named preset.

Here is the output of each call, respectively:
{‘BG-Krita2. Gradient background for brush preset icons.’: <PyKrita.krita.Resource object at 0x7f2e5bfb51f0>, ‘Foreground to Background’: <PyKrita.krita.Resource object at 0x7f2e5bfb5280>, ‘Foreground to Transparent’: <PyKrita.krita.Resource object at 0x7f2e5bfb5550>, ‘GPS FG Glare’: <PyKrita.krita.Resource object at 0x7f2e5bfb53a0>, ‘GPS Fire Blueish’: <PyKrita.krita.Resource object at 0x7f2e5bfbe040>, ‘GPS Fire Burning Cloud’: <PyKrita.krita.Resource object at 0x7f2e5bfbe0d0>, ‘GPS Fire Dust’: <PyKrita.krita.Resource object at 0x7f2e5bfbe160>, ‘GPS Fire Dust Blended’: <PyKrita.krita.Resource object at 0x7f2e5bfbe1f0>, ‘GPS Fire Incandescent’: <PyKrita.krita.Resource object at 0x7f2e5bfbe280>, ‘GPS Fire Life Span’: <PyKrita.krita.Resource object at 0x7f2e5bfbe310>, ‘GPS Haze and Atmosphere’: <PyKrita.krita.Resource object at 0x7f2e5bfbe3a0>, ‘GPS Light Saber (Use FG color)’: <PyKrita.krita.Resource object at 0x7f2e5bfbe430>, ‘GPS Nature Pure greens’: <PyKrita.krita.Resource object at 0x7f2e5bfbe4c0>, ‘GPS Nature browns copy’: <PyKrita.krita.Resource object at 0x7f2e5bfbe550>, ‘GPS Nature random greens’: <PyKrita.krita.Resource object at 0x7f2e5bfbe5e0>, ‘GPS Nature_Grass’: <PyKrita.krita.Resource object at 0x7f2e5bfbe670>, ‘GPS Simple Smoke’: <PyKrita.krita.Resource object at 0x7f2e5bfbe700>, ‘GPS Steel Bars’: <PyKrita.krita.Resource object at 0x7f2e5bfbe790>, ‘GPS eye (Blue)’: <PyKrita.krita.Resource object at 0x7f2e5bfbe820>}

[‘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’, ‘gaussianhighpass’, ‘gaussiannoisereducer’, ‘gradientmap’, ‘halftone’, ‘height to normal’, ‘hsvadjustment’, ‘indexcolors’, ‘invert’, ‘lens blur’, ‘levels’, ‘maximize’, ‘mean removal’, ‘minimize’, ‘motion blur’, ‘noise’, ‘normalize’, ‘oilpaint’, ‘palettize’, ‘perchannel’, ‘phongbumpmap’, ‘pixelize’, ‘posterize’, ‘raindrops’, ‘randompick’, ‘roundcorners’, ‘sharpen’, ‘smalltiles’, ‘threshold’, ‘unsharp’, ‘wave’, ‘waveletnoisereducer’]

The gradient map filter doesn’t store a gradient preset, it stores a gradient in xml format. So I guess you would have to somehow get the xml representation of the gradient preset and put that in the gradientXML property of the gradient map properties and then load them in the filter. But I don’t know if all that is possible through Python.

Bingo! Exactly what I would like Krita to do. It has it stored as a preset, but the Python Scripter API doesn’t seem to provide access to it. At the moment, I am loading it from disk, extracting data with lxml and pushing it into the gradientXML. This manual step of parsing the data and configuring the gradient (when Krita has it stored already anyway) is what I was trying to avoid.