Channels to Layers

Hi

I’m testing Krita plugin creation :slight_smile:

Here is the first result of what I’ve made: Channels to Layers

What is Channels to Layers?

Channels to Layer is a Python plugin made for Krita (free professional and open-source painting program).

It allows to split layer channels in sub-layers:

  • RGB
  • CMY
  • CMYK
  • RGB as grayscale values
  • CMY as grayscale values
  • CMYK as grayscale values

Download & Install

You can download it on Github:

Installation process is defined on github page.

Bugs

Plugin has been tested with Krita 4.2.9 (appimage) on Linux Debian 10

  • Not tested on Windows/Mac OS
  • Not tested on Linux non-appimage (ie: appimage include Python 3.8 + needed Qt libraries)

There’s might be some bugs but and code may not be optimised, but it’s a first release :wink:

Use

Use of plugin is quite simple:

  • Select a paint layer layer in active document (layer must be 8bits RGBA layer)
  • Execute script Tools > Scripts > Channels to layers
  • Choose options from user interface and click OK

Why Channels to Layers

In fact this plugin is not really useful for me :sweat_smile:

By doing it, main goal for me were:

  • To practice Krita plugin creation with simple and basic functionalities to understand plugin implementation, mechanisms and Krita API
  • To create a Github account and start to practice it

Enjoy

Grum999

10 Likes

Oh, that’s pretty interesting – both for the functionaly and for the approach. I would never have thought of using fill layers here.

2 Likes

Oh thanks :sweat_smile:

In fact, first version I started to write, I was using pixelData() and working byte per byte
But python is a slow interpreted language and not really designed to work with heavy amount of data…

So started to look how to use Krita functionalities as it’s written in C++ and compiled, it’s faster to manipulate data on layers.

Grum999

No in fact this plugin will be really useful for people who will make screen prints and also for color separators etc. This is awesome.

1 Like

Would you be ago with adding this Krita’s default set of Python plugins?

Yes of course :hugs:

Krita’s developers team made a such wonderful work that it would be a pleasure for me to see it in the default set of Python plugin :blush:

Grum999

This seems to work on Windows. For those like me who don’t know basics, to install this plugin, leave the file unzipped, and put it in a folder of your choice. Open Krita and go up to tools/scripts/import python plugin…
select the zip file and you’ll get a confirmation that the plugin has installed. Then open settings/python plugin manager and find the channels to layers plugin in the list and activate it. You might then have to re-open Krita and load up an image, select a layer and go up to tools/scripts and you should see channels to layers listed. Works as advertised.

1 Like

Thanks for information :+1:

In fact, installation procedure was provided on github page, I’ve updated the initial topic about this (thank for reminder, I didn’t take care that it was a good thing to put information here :wink:)

Grum999

I can just add the plugin myself, but ideally you’d get a KDE identity account and create a merge request on invent.kde.org :slight_smile:

Fastest solution if you’re interested to have the plugin as soons as possible in Krita’s repository
But maybe not the best long term solution (for plugin improvements and bug fix…)

If you can wait, I’ll do it by myself in few days

Ok
As I’m used to code, but I’m completely a newbie with git and even more invent.kde.org

I have few questions:

Many questions… :grimacing:

Grum999

Yes, I would prefer it if you did this yourself :slight_smile:

Github only mirrors KDE’s git repositories. Because we’re a pretty dedicated free software community we cannot give the hosting of our work out to Microsoft or another commercial entity. Which is also why we have our own instance of gitlab.

When it is merged, yes. All commits are immediately mirrored. The merge request itself isn’t mirrored.

That should be a simple matter of forking krita on invent, then adding your fork as another origin to your checkout, push your changes to your fork and make a merge request. If you do this from the terminal or commandline, there’ll be a link you can use to create the merge request.

I’d close it, it’s always best to have one source where you work on the plugin.

The latter :slight_smile:

Not an answer to the questions, i just wanted to point you to the documentation regarding submitting patches - https://docs.krita.org/en/untranslatable_pages/intro_hacking_krita.html#contributing-patches

1 Like

Oh thanks!
I’ll read it after work :slight_smile:

Grum999

I understand, it make sense :slight_smile:

I’ve created my KDE Identity profile.
Next friday as I’ll be out of office, I’ll try to do the merge request at this moment.

Grum999

This runs well on the 4.2.9 appimage on Debian 10 so thank you :slight_smile:
Sadly, it crashes the latest ‘stable’ 4.3.0 and the latest 5.0.0 nightly appimages.

Thanks for feedback !
I’ll download last builds and check for the problem

Grum999

That might be because of a fix I added for a memory leak in the scripting library… Which has unfortunate side effects. If so, I’m trying to find time to fix that, but that turns out to be a bit hard.

Looking where the crash occurs, it seems that this method call doesn’t work anymore and generate the crash:
newLayer = currentProcessedLayer.mergeDown()

I tried to catch an exception in script execution:

try:
    newLayer = currentProcessedLayer.mergeDown()
except Exception as e:
    print(e)

But it doesn’t change anything, Krita crash violently

Grum999

Yes, a crash is not an exception. I will need to look into this.

@raghukamath @halla
Ok, I created an identity for invent.kde.org

I’ve followed instruction provided:

  • Repository is forked (Grum999 / Krita · GitLab)
  • I made a clone on my computer
  • I have created a branch on my computer (named grum/Channels2Layers)
  • I made the commit (to my branch)

But now, I’m blocked for the push to the repository

Given command git push doesn’t work, git inform me that I have to do git push --set-upstream origin grum/Channels2Layers so, I use the recommended command but here is the result (sorry, git message are in french but message from repository -for what I understand- are in English)

Username for 'https://invent.kde.org': grum
Password for 'https://grum@invent.kde.org': 
Énumération des objets: 13, fait.
Décompte des objets: 100% (13/13), fait.
Compression par delta en utilisant jusqu'à 8 fils d'exécution
Compression des objets: 100% (10/10), fait.
Écriture des objets: 100% (10/10), 142.88 KiB | 7.94 MiB/s, fait.
Total 10 (delta 3), réutilisés 0 (delta 0)
remote: Audit failure - Commit 663417e55cc53ccff2d51b16a314cffb7e44f95c - Non-full name: Grum
remote: Audit failure - Commit 663417e55cc53ccff2d51b16a314cffb7e44f95c - Non-full name: Grum
remote: Audit failure - Commit 663417e55cc53ccff2d51b16a314cffb7e44f95c - Seemingly invalid email address: 
remote: Audit failure - Commit 663417e55cc53ccff2d51b16a314cffb7e44f95c - Seemingly invalid email address: 
remote: Push declined - commits failed audit
remote: error: hook declined to update refs/heads/grum/Channels2Layers
To https://invent.kde.org/grum/krita.git
 ! [remote rejected]       grum/Channels2Layers -> grum/Channels2Layers (hook declined)
error: impossible de pousser des références vers 'https://invent.kde.org/grum/krita.git'

Username/Password seems to be good (tried with other value and error message ‘access denied’ is returned)
So the ‘audit failure’ seems to be relative to my profile, but I’m not sure about the message concerning my ‘full name’ and my ‘email address’

From invent.kde.org, I properly receive email to the defined email adress
I also created and added a ssh keys (following given instruction) but it does not change anything… :confused:

Do you have any idea about this error message and how I can fix it?

Grum999