New Krita Scripting website feedback

I have been working on a new Python scripting site to help people with a few various things:

  • What areas can be scripted with Krita
  • Focus on simple examples explaining a topic
  • Action dictionary to more easily find available actions
  • Icon library to help people see and use icons that come with Krita
  • Some references to help with building plugins and API references

Here is the WIP site.
https://amazing-elion-61c814.netlify.app/

This will eventually be a new URL under krita.org. I was seeing if people could take a look at it and provide feedback. I am particularly interested in topics that might be good to cover that I missed, or if people want me to go deeper in specific topics.

18 Likes

Thanks a lot for this! I was actually thinking of writing some scripts to automate a lot of repetitive actions, and this is massively helpful to get started.

I just skimmed a couple of sections (for now) and I think I found one mistake: the code snippet in the “Removing layers and performing more actions” subsection of the “layers” section is duplicating the layer instead of deleting it (I guess it was a bad copy-paste, as the same snippet appears earlier).

Also, something that I feel may need more clarification is the plugin location. For linux it states that they are placed under ~/.local/share/krita/pykrita, but I assume that this is not true for snap/flatpak installations. It think would be helpful to also mention the location for these alternate installation methods, even if they are community maintained.

I’ll try to do a more in depth read later this week, and come back if I find something.

1 Like

One thing is for sure: such resource was really missing!

1 Like

it looks so Awesome!!!

1 Like

This is amazing, really helpful for people who want to learn scripting in krita. Here is some feedback for it:

  1. In the “Dialog and Buttons”, “Dockers” and “Menu” session I think some images showing the expected results for the script would be good, since these sessions deal with the user interface i think they are the most critical areas to show the final result.

  2. I dont know if I missed it but i think a link to the krita api page would be good.

other than that looks great!

1 Like

Thanks for the feedback. I originally had some of that layers code in the document section, then moved it once I thought it would be better to have Layers have its own lesson. I can clean that up.

I might have to ask about the flatpak or appimages. I didn’t think those were stored in a different location. The stuff in the local folder are just user related files, so I thought flatpak also stored things there. I can do a bit of digging.

That is a good idea of adding a few more screenshots with results. A lot of these simple examples just print something out in the output, so it didn’t seem that useful for many of examples. The examples that have a UI would probably be good to show the results though.

3 posts were split to a new topic: Fill button doesn’t work

Looking through the API a bit more, I am noticing there are a few areas I could add to the site

  1. Resources API - How to change brush presets, and properties like the brush size, opacity, and flow. This also includes things like getting and setting foreground and background colors
  2. Selections API - How to create selections, modify them, and remove them
  3. Krita Widgets - Custom UI componenets you can use in your scripts like the preset chooser, color palettes, and the scratchpad

I love the idea of this :slight_smile: It’s cool.

Personally I think more examples in the future would be good just to give people more things to learn from.

The major part I think that would be cool is a a big chapter about how to work with Krita documentation (I did see the pyq and krita api parts at the bottom) as that will be the biggest hurdle for anyone trying to get into this. It’s not really made for humans who are not working on Krita or more involved in this kind of thing.

Well, at least I think having thorough read on that can alleviate a lot of pain and help people not to give up or at least I assume this is focused not just on veteran programmers but also on people who are trying to use Krita and maybe tinker something for it on while they might not be python or C++ specialists by a trade? :smiley: , and not just pain but showing how to get things done working together with documentation will make things easier on you as a creator and maintainer of this project (how is it about that fishing rod and the fish? Give fish and you feed, teach fishing and you can relax while they bring the fish? ;0)

I don’t know if this is part of the project scope or not I just, when learning new APIs, libs, languages, really appreciate if the devs/or someone else shows projects/code when they bluntly show/describe how to get to that together with documentation as that makes it more straightforward and much quicker to get me get comfortable in anything I would try to create or would try to study (I’m sure you know how it is, you as a dev know where to find what, what things mean but a new person even if given a link will be wondering how would I decide this is the part I needed or what this means and so on).

(I don’t know if my idea got across, is the description to difficult to understand, sorry I’d love to describe it better)

Definitely nice that your are putting together something that can get people going with scripting in krita keep going at this it’s a great work!

1 Like

I think the biggest issue when starting out with scripting is people don’t even know what areas you can script - which I am trying to go over with all the basic sections. API pages are for developers. I think linking to an API page is not a good way to teach people when starting off. It is definitely a more advanced thing that I am trying to be careful referencing.

For the start of this site, I was going to see what type of scripts and plugins people are making…and where they might be struggling. Then expand on the areas where people are having a hard time. This isn’t a learn how to program site, so I am not sure how knowledge people have with basic concept like variables and “if” statement. I am sure I could have a primer if there a lot of people who aren’t understanding more general programming concepts.

3 Likes

I certainly didn’t mean it as a “learn programming” source if it sounded like that. I just think that if someone is supposed to put together a project of their own then having examples is always great but what are they going to do when they want to do something different. It’s nice to either have a solid docs like what MDN does with javascript or what PHP has as a manual, so as you started it with concepts that have a general use in most if not all plugins possible for Krita which is great there will be a time for all these plugins when the creator will have to write down some part which is related to functionality he is trying to achieve.

Here might be where the misunderstanding came from? I did not mean by this to give a 101 programming class just a chapter or hints how to use the documentation which is just generated by a script rather than in a readable format for someone new to this (they can very well be programmers but the docs don’t necessarily have to be much help to them anyway or a be a huge headache ;-)).
So I again I did not mean to go through programming concepts, basics or anything like that, just to maybe show in some separate chapter, hint blocks, … how you got that piece of code you showed in a lesson (doesn’t have to be with all the code, could very well be showed on one example at the end or something).

But that’s just how I see it, you might not need docs at lesson one but no matter how you look at it you will probably need docs and work with it after the last lesson, won’t you? :wink:

Maybe it’s not needed at all, maybe not at the beginning, I just wanted to put up a suggestion nothing more.

Either way I’m looking forward to seeing this when you feel it’s finished and ready to fully send out to the world :nerd_face:

Take a look through the current PyQt and Krita API pages on the new scripting site. What questions do you still have after looking through those pages? That lists everything that is available, much more than what I am covering.

Those API pages are designed to help you navigate through the API pages to learn things outside the main concepts. I am sure there are more things I could elaborate or clarify in those.

Answering this question “how you get that piece of code” has multiple answers.

  1. I know some parts of the code and know where to look in the API
  2. I don’t know the code and have to look at the API
  3. I cannot figure it out in the API, so do internet search on it.
  4. If nothing comes back up on the internet, I might ask the developers directly or post here

Maybe I could explain my personal process for how to do research when doing programming projects. This would be a bit more general advice. The topic of how to do research might be something newer programmers don’t realize programmers constantly have to do…regardless of their skill level.

1 Like

maybe a copy and paste selection example? simple stuff like that

Hi @scottyp

Thanks for this, it’s really useful (I think if this site was available when I started to understand how to create a plugin, it might be easier for me to start :wink:)

But reading this part: Krita Scripting School

I’m not completly agree with what I can read.

Pros of plugins

2) Portable and easy for non-technical people to use

The Python language, even if it’s an easy language to understand and learn, still needs some minimal technical skills.
For people that already have some difficulties to use a computer and/or a basic software functionalities, I’m not sure they’ll be able to create scripts

3) Provide additional functionality that is harder to do with normal scripting

What is normal scripting?

Cons of plugins

1) Slower to develop. Krita needs to restart to test any changes

On my side, I don’t restart Krita to tests changes on code (even if there’s multiple imported python libraries, it’s possible to manage: that’s tricky but it’s possible)

And I think that coding a Python script is faster than C++: the compilation time to build Krita on each modification + execution might be very longer than modify a script and (eventually) restart Krita

2) More files and code for doing simple things

For this, I’m not totally agree.
It will depends of what you want to do, but Python is a high language level with high level methods and classes, that allows to do things in few lines compared to basics classes and methods C++

For Cons, I will tell:

  • No access to ALL Krita functions and possibilities
  • Slow execution (compared to compiled code)

Grum999

2 Likes

This is so amazing

@scottyp
From this page: Krita Scripting School

I took time to search configurations for filters (Krita 4.3.0)

You can use it and provide it on the documentation page if you want, it could be useful for other to already have parameters list with domain values for each filter (and, list of filter that doesn’t work from scripting, because if you know which filters doesn’t work from scripting, you won’t loose time to understand what’s currently happening with your code :sweat_smile:…)

Note

  • Provided range values are from user interface; some filters can accept values outside range provided by interface

Working filters


Filter autocontrast (Adjust > Auto Contrast)
No parameters


Filter blur (Blur > Blur…)

    'halfWidth'                     0+
    'halfHeight'                    0+
    'rotate'                        [0 to 360]
    'strength'                      [0 to 100]
    'shape'                         [0 (Circle), 
                                     1 (Rectangle)]

Filter burn (Adjust > Burn…)

    'type'                          [0 (Shadows), 
                                     1 (Midtone), 
                                     2 (Highlights)]
    'exposure'                      [0 to 1]

Filter colorbalance (Adjust > Color Balance…)

    'cyan_red_midtones'             [-100 to 100]
    'yellow_green_midtones'         [-100 to 100]
    'magenta_blue_midtones'         [-100 to 100]
    'cyan_red_shadows'              [-100 to 100]
    'yellow_green_shadows'          [-100 to 100]
    'magenta_blue_shadows'          [-100 to 100]
    'cyan_red_highlights'           [-100 to 100]
    'yellow_green_highlights'       [-100 to 100]
    'magenta_blue_highlights'       [-100 to 100]
    'preserve_luminosity'           [true, false]

Filter colortoalpha (Colors > Color to Alpha…)

    'targetcolor'                   QColor() or '#rrggbb'
    'threshold'                     [1 to 255]

Filter desaturate (Adjust > Desaturate…)

    'type'                          [0 (Lightness), 
                                     1 (Luminosity: ITU-R BT.709), 
                                     2 (Luminosity: ITU-R BT.601), 
                                     3 (Average), 
                                     4 (Min), 
                                     5 (Max)]

Filter dodge (Adjust > Dodge…)

    'type'                          [0 (Shadows), 
                                     1 (Midtone), 
                                     2 (Highlights)]
    'exposure'                      [0 to 1]

Filter edge detection (Edge detection > Edge detection…)

    'type'                          ['prewitt', 'sobol', 'simple']
    'horizRadius'                   0+
    'vertRadius'                    0+
    'output'                        ['pythagorean' (All sides), 
                                     'xGrowth' (Top Edge), 
                                     'xFall' (Bottom Edge), 
                                     'yGrowth' (Right Edge), 
                                     'yFall' (Left Edge), 
                                     'radian' (Direction in Radians)]
    'lockAspect'                    [true, false]
    'transparency'                  [true, false]

Filter emboss all directions (Emboss > Emboss all direction)
No parameters


Filter emboss horizontal and vertical (Emboss > Emboss horizontal & vertical)
No parameters


Filter emboss horizontal only (Emboss > Emboss horizontal only)
No parameters


Filter emboss laplascian (Emboss > Emboss laplacian)
No parameters


Filter emboss vertical only (Emboss > Emboss vertical only)
No parameters


Filter gaussian blur (Blur > Gaussian blur…)

    'horizRadius'                   0.0+
    'vertRadius'                    0.0+
    'lockAspect'                    [true, false]

Filter gaussianhighpass (Edge detection > Gaussian high pass…)

    'blurAmount'                    0.0+

Filter gaussiannoisereducer (Enhance > Gaussian noise reduction…)

    'threshold'                     [0 to 255]
    'windowsize'                    [0 to 10]

Filter height to normal (Edge detection > Height to normal map…)

    'type'                          ['prewitt', 'sobol', 'simple']
    'horizRadius'                   0+
    'vertRadius'                    0+
    'channelToConvert'              [0 (Blue), 
                                     1 (Green), 
                                     2 (Red), 
                                     3 (Alpha)]
    'lockAspect'                    [true, false]
    'redSwizzle'                    [0 (X+), 
                                     1 (X-), 
                                     2 (Y+), 
                                     3 (Y-), 
                                     4 (Z+), 
                                     5 (Z-)]
    'greenSwizzle'                  [0 (X+), 
                                     1 (X-), 
                                     2 (Y+), 
                                     3 (Y-), 
                                     4 (Z+), 
                                     5 (Z-)]
    'blueSwizzle'                   [0 (X+), 
                                     1 (X-), 
                                     2 (Y+), 
                                     3 (Y-), 
                                     4 (Z+), 
                                     5 (Z-)]

Filter hsvadjustment (Adjust > HSV Adjustment…)

    'type'                          [0 (Hue/Saturation/Value), 
                                     1 (Hue/Saturation/Lightness), 
                                     2 (Hue/Saturation/Intensity), 
                                     3 (Hue/Saturation/Luma), 
                                     4 (Blue Chroma/Red Chroma/Luma)]
    'colorize'                      [true, false]
    'compatibilityMode'             [true, false]
    'h'                             Type(0,1,2,3):  Hue         [-180 to 180] 
                                    Type(4):        Yellow-Blue [-100 to 100]
    's'                             Type(0,1,2,3):  Saturation  [-100 to 100]
                                    Type(4):        Green-Red   [-100 to 100]
    'v'                             Type(0):        Value       [-100 to 100]
                                    Type(1):        Lightness   [-100 to 100]
                                    Type(2):        Intensity   [-100 to 100]
                                    Type(3,4):      Luma        [-100 to 100]

Filter invert (Adjust > Invert)
No parameters


Filter lens blur (Blur > Lens blur…)

    'irisShape'                     ['Triangle', 'Quadrilateral (4)', 'Pentagon (5)', 'Hexagon (6)', 'Heptagon (7)', 'Octagon (8)']
    'irisRadius'                    0+
    'irisRotation'                  [0 to 360]

Filter levels (Adjust > Levels…)

    'blackvalue'                    [0 to 255]
    'whitevalue'                    [0 to 255]
    'gammavalue'                    [0.1 to 10.0]
    'outblackvalue'                 [0 to 255]
    'outwhitevalue'                 [0 to 255]

Filter maximize (Colors > Maximize Channel)
No parameters


Filter minimize (Colors > Maximize Channel)
No parameters


Filter motion blur (Blur > Motion blur…)

    'blurAngle'                     [-360 to 360]
    'blurLength'                    0+

Filter noise (Other > Random noise…)

    'level'                         [0 to 99]
    'opacity'                       [0 to 99]
    'seedThreshold'                 [0.0 to 1.0]
    'seedRed'                       [0.0 to 1.0]
    'seedGreen'                     [0.0 to 1.0]
    'seedBlue'                      [0.0 to 1.0]

Filter normalize (Map > Normalize)
No parameters


Filter oilpaint (Artistic > Oilpaint…)

    'brushSize'                     [1 to 5]
    'smooth'                        [10 to 255]

Filter palettize (Map > Paletize…)

    'palette'                       (string)
    'colorspace'                    [0 (Lab), 
                                     1 (RGB)]
    'ditherEnabled'                 [true, false]
    'alphaEnabled'                  [true, false]
    'alphaMode'                     [0 (Clip), 
                                     1 (Index), 
                                     2 (Dither)]
    'alphaClip'                     [0.0 to 1.0]
    'alphaIndex'                    [0 to n] (n = number of colors in selected palette)
    'alphaDither/noiseSeed'         0+
    'alphaDither/pattern'           (string)
    'alphaDither/patternValueMode'  [0 (Auto), 
                                     1 (Lightness), 
                                     2 (Alpha)]
    'alphaDither/spread'            [0.0 to 1.0]
    'alphaDither/thresholdMode'     [0 (Pattern), 
                                     1 (Noise)]
    'dither/colorMode'              [0 (Per Channel Offset), 
                                     1 (Nearest Color)]
    'dither/noiseSeed'              0+
    'dither/offsetScale'            [0.0 to 1.0]
    'dither/pattern'                (string)
    'dither/patternValueMode'       [0 (Auto), 
                                     1 (Lightness), 
                                     2 (Alpha)]
    'dither/spread'                 [0.0 to 1.0]
    'dither/thresholdMode'          [0 (Pattern), 
                                     1 (Noise)]

Filter phongbumpmap (Map > Phong Bumpmap…)

    'Azimuth0'                      [0 to 360]                    // Light Source 1
    'Azimuth1'                      [0 to 360]                    // Light Source 2
    'Azimuth2'                      [0 to 360]                    // Light Source 3
    'Azimuth3'                      [0 to 360]                    // Light Source 4
    'Inclination0'                  [0 to 90]                     // Light Source 1
    'Inclination1'                  [0 to 90]                     // Light Source 2
    'Inclination2'                  [0 to 90]                     // Light Source 3
    'Inclination3'                  [0 to 90]                     // Light Source 4
    'illuminantColor0'              QColor                        // Light Source 1
    'illuminantColor1'              QColor                        // Light Source 2
    'illuminantColor2'              QColor                        // Light Source 3
    'illuminantColor3'              QColor                        // Light Source 4
    'illuminantIsEnabled0'          [true,false]                  // Light Source 1
    'illuminantIsEnabled1'          [true,false]                  // Light Source 2
    'illuminantIsEnabled2'          [true,false]                  // Light Source 3
    'illuminantIsEnabled3'          [true,false]                  // Light Source 4
    'heightChannel'                 ['Blue', 'Green', 'Red']    
    'useNormalMapIsEnabled'         [true,false]                
    'ambientReflectivity'           [0.0 to 1.0]                
    'diffuseReflectivity'           [0.0 to 1.0]                
    'diffuseReflectivityIsEnabled'  [true,false]                
    'specularReflectivity'          [0.0 to 1.0]                
    'specularReflectivityIsEnabled' [true,false]                
    'shinynessExponent'             [1 to 200]                

Filter pixelize (Artistic > Pixelize…)

    'pixelWidth'                    [2 to 512]
    'pixelHeight'                   [2 to 512]

Filter posterize (Artistic > Posterize…)

    'pixelWidth'                    [2 to 512]

Filter raindrops (Artistic > Raindrops…)

    'dropsize'                      [1 to 200]
    'number'                        [1 to 500]
    'fishEyes'                      [1 to 100]
    'seed'                          0+

Filter randompick (Other > Random pick…)

    'level'                         [0 to 99]
    'opacity'                       [1 to 500]
    'windowsize'                    [1 to 100]
    'seedH'                         0+
    'seedV'                         0+
    'seedThreshold'                 0+

Filter roundcorners (Map > Round corners…)
note: works on (0,0,width,height) area only

    'radius'                        [2 to 100]

Filter sharpen (Enhance > Sharpen)
No parameters


Filter smalltiles (Map > Small tiles…)
note: strange result if area is not image full area

    'numberOfTiles'                 [2 to 5]

Filter threshold (Adjust > Threshold…)

    'threshold'                     [0 to 255]

Filter waveletnoisereducer (Enhance > Wavelet Noise Reduced…)

    'threshold'                     [0 to 255]

Not working filters


Filter emboss (Emboss > Emboss…)
FILTER DO NOT WORK PROPERLY FROM SCRIPT
Result do not match result obtained from Krita user interface

    'depth'                         0+

Filter halftone (Emboss > Emboss…)
FILTER DO NOT WORK PROPERLY FROM SCRIPT
Result do not match result obtained from Krita user interface (corrupted result)


Filter colortransfer (Colors > Color Transfer…)
FILTER DO NOT WORK PROPERLY FROM SCRIPT

    'filename'                      (String) ==> not taken in account? or invalid property name?

Filter mean removal (Enhance > Mean removal)
FILTER DO NOT WORK PROPERLY FROM SCRIPT
Result do not match result obtained from Krita user interface (corrupted result)


Filter unsharp (Enhance > UNsharp mask)
FILTER DO NOT WORK PROPERLY FROM SCRIPT
Result do not match result obtained from Krita user interface

    'amount'                        [0.0 to 99.99]
    'halfSize'                      [0.0 to 99.99]
    'threshold'                     [0 to 99]
    'lightnessOnly'                 [true, false]    

Filter wave (Other > Waves…)
FILTER DO NOT WORK PROPERLY FROM SCRIPT
Result do not match result obtained from Krita user interface

    'horizontalshape'               [0 (Sinusoidal), 
                                     1 (Triangle)]
    'horizontalamplitude'           [0 to 100]
    'horizontalshift'               [0 to 99]
    'horizontalwavelength'          [1 to 100]
    'verticalshape'                 [0 (Sinusoidal), 
                                     1 (Triangle)]
    'verticalamplitude'             [0 to 100]
    'verticalshift'                 [0 to 99]
    'verticalwavelength'            [1 to 100]

Not yet analyzed filters


Filter asc-cdl (Adjust > Slope, Offset, Power…)
FILTER NOT YET ANALYZED
Need to analyze code (and currently not able to understand user interface and results :upside_down_face:)


Filter crosschannel (Adjust > Cross Channel adjustment curves…)
FILTER NOT YET ANALYZED


Filter gradientmap (Map > Gradient map…)
FILTER NOT YET ANALYZED
Need to analyze code (seems to use a XML content as parameter property?)


Filter indexcolors (Artistic > Index colors…)
FILTER NOT YET ANALYZED

    'LFactor'                       ?
    'aFactor'                       ?
    'bFactor'                       ?
    'reduceColorsEnabled'           [true, false]
    'colorLimit'                    [3 to 256]
    'alphaSteps'                    [0 to 32]
    'paletteGen'                    Array of Bytes
                                    Ramps & Gradient steps (need to analyse how to build the byte array)

Filter perchannel
FILTER NOT YET ANALYZED
From which menu?


Grum999

3 Likes

This plugins pro/con list is comparing writing scripts in scripter…to writing scripts in a plugin. Maybe “normal scripting” needs to say “writing scripts in scripter”. I am not sure how much that changes your questions, but I see you mention things like Python and C++ which isn’t very related to what this pro/con list is going over.

For this filters list, that is pretty neat. Did you generate this through a script that you can share? This seems useful. If this is manually made though and I had to make a page on the scripting site, I also don’t want to manage every filter’s parameters and every change that happens with it as filters change and the state changes. Maybe I could just link to this thread…but that might be a bit confusing since there is so much other conversation in here.

Oh ok, it make sense :sweat_smile:

In fact, I didn’t understood that “Why use plugins” section was comparing use of Scripter plugin to execute a python script, and a plugin executed from Krita.

I was thinking about Python plugins vs. native Krita function implementation :blush:

Grum999