# Channels to Layers

**URL:** <https://krita-artists.org/t/channels-to-layers/5350>\
**Category:** Plugins and Scripts\
**Created:** [April 11, 2020, 8:50am UTC](https://krita-artists.org/t/channels-to-layers/5350 "2020-04-11T08:50:00Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grum999](https://krita-artists.org/user_avatar/krita-artists.org/grum999/32/66488_2.png) [@Grum999](https://krita-artists.org/u/Grum999)\
**Post date:** [April 11, 2020, 8:50am UTC](https://krita-artists.org/t/channels-to-layers/5350/1 "2020-04-11T08:50:00Z")

</div>

Hi

I’m testing Krita plugin creation 🙂

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

 ![channels2layers](https://krita-artists.org/uploads/default/original/2X/7/7a648098fe184ab72e167a25e8ad9f65dd226d79.jpeg)

## What is Channels to Layers?

_Channels to Layer_ is a Python plugin made for [Krita](https://github.com/KDE/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:

- [Zip file](https://github.com/Grum999/Channels2Layers/releases/download/V1.0.0/channels2layers.zip)
- [Source code](https://github.com/Grum999/Channels2Layers)

Installation process is defined on [github page](https://github.com/Grum999/Channels2Layers).

# 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 😉

# 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 😅

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

---

<div class="post-metadata">

**Author:** ![halla](https://krita-artists.org/user_avatar/krita-artists.org/halla/32/18581_2.png) [@halla](https://krita-artists.org/u/halla)\
**Post date:** [April 11, 2020, 9:14am UTC](https://krita-artists.org/t/channels-to-layers/5350/2 "2020-04-11T09:14:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Grum999](https://krita-artists.org/user_avatar/krita-artists.org/grum999/32/66488_2.png) [@Grum999](https://krita-artists.org/u/Grum999)\
**Post date:** [April 11, 2020, 9:31am UTC](https://krita-artists.org/t/channels-to-layers/5350/3 "2020-04-11T09:31:12Z")

</div>

Oh thanks 😅

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

---

<div class="post-metadata">

**Author:** ![raghukamath](https://krita-artists.org/user_avatar/krita-artists.org/raghukamath/32/59144_2.png) [@raghukamath](https://krita-artists.org/u/raghukamath)\
**Post date:** [April 11, 2020, 1:33pm UTC](https://krita-artists.org/t/channels-to-layers/5350/4 "2020-04-11T13:33:27Z")

</div>

> [@Grum999](#):
>
> In fact this plugin is not really useful for me

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.

---

<div class="post-metadata">

**Author:** ![halla](https://krita-artists.org/user_avatar/krita-artists.org/halla/32/18581_2.png) [@halla](https://krita-artists.org/u/halla)\
**Post date:** [April 11, 2020, 1:50pm UTC](https://krita-artists.org/t/channels-to-layers/5350/5 "2020-04-11T13:50:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Grum999](https://krita-artists.org/user_avatar/krita-artists.org/grum999/32/66488_2.png) [@Grum999](https://krita-artists.org/u/Grum999)\
**Post date:** [April 11, 2020, 1:59pm UTC](https://krita-artists.org/t/channels-to-layers/5350/6 "2020-04-11T13:59:21Z")

</div>

Yes of course 🤗

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 😊

Grum999

---

<div class="post-metadata">

**Author:** ![djwaterman](https://krita-artists.org/user_avatar/krita-artists.org/djwaterman/32/231301_2.png) [@djwaterman](https://krita-artists.org/u/djwaterman)\
**Post date:** [April 11, 2020, 2:27pm UTC](https://krita-artists.org/t/channels-to-layers/5350/7 "2020-04-11T14:27:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Grum999](https://krita-artists.org/user_avatar/krita-artists.org/grum999/32/66488_2.png) [@Grum999](https://krita-artists.org/u/Grum999)\
**Post date:** [April 11, 2020, 2:55pm UTC](https://krita-artists.org/t/channels-to-layers/5350/8 "2020-04-11T14:55:04Z")

</div>

> [@djwaterman](#):
>
> This seems to work on Windows

Thanks for information 👍

> [@djwaterman](#):
>
> For those like me who don’t know basics, to install this plugin, […]

In fact, installation procedure was provided on [github page](https://github.com/Grum999/Channels2Layers), 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 😉)

Grum999

---

<div class="post-metadata">

**Author:** ![halla](https://krita-artists.org/user_avatar/krita-artists.org/halla/32/18581_2.png) [@halla](https://krita-artists.org/u/halla)\
**Post date:** [April 14, 2020, 11:52am UTC](https://krita-artists.org/t/channels-to-layers/5350/9 "2020-04-14T11:52:11Z")

</div>

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](http://invent.kde.org) 🙂

---

<div class="post-metadata">

**Author:** ![Grum999](https://krita-artists.org/user_avatar/krita-artists.org/grum999/32/66488_2.png) [@Grum999](https://krita-artists.org/u/Grum999)\
**Post date:** [April 14, 2020, 12:25pm UTC](https://krita-artists.org/t/channels-to-layers/5350/10 "2020-04-14T12:25:54Z")

</div>

> [@halla](#):
>
> I can just add the plugin myself

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

> [@halla](#):
>
> ideally you’d get a KDE identity account and create a merge request on [invent.kde.org](http://invent.kde.org)

Ok  
As I’m used to code, but I’m completely a newbie with git and even more [invent.kde.org](http://invent.kde.org)

I have few questions:

- What’s the difference between:  
– [GitHub - KDE/krita: Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.](https://github.com/KDE/krita) (I already have a github account, seems to be based on a proprietary solution)  
– [Graphics / Krita · GitLab](https://invent.kde.org/kde/krita) (account not yet created, seems to be based on open source gitlab solution)
- If I made a merge request on [Graphics / Krita · GitLab](http://invent.kde.org/kde/krita), the result is also available on github?
- Is it possible to merge from current plugin [github repository](https://github.com/Grum999/Channels2Layers) or do I have to do it from scratch ?
- What is recommended for the current plugin repository?  
– Do I close the project?  
– Do I let it alive?
- What’s the recommended workflow to update the plugin ?  
– 1st update github repo and then ask for a merge to [invent.kde.org](http://invent.kde.org) ?  
– Work directly with [invent.kde.org](http://invent.kde.org)?

Many questions… 😬

Grum999

---

<div class="post-metadata">

**Author:** ![halla](https://krita-artists.org/user_avatar/krita-artists.org/halla/32/18581_2.png) [@halla](https://krita-artists.org/u/halla)\
**Post date:** [April 14, 2020, 12:51pm UTC](https://krita-artists.org/t/channels-to-layers/5350/11 "2020-04-14T12:51:42Z")

</div>

Yes, I would prefer it if you did this yourself 🙂

> [@Grum999](#):
>
> - What’s the difference between:  
> – [GitHub - KDE/krita: Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.](https://github.com/KDE/krita) (I already have a github account, seems to be based on a proprietary solution)  
> – [Graphics / Krita · GitLab](https://invent.kde.org/kde/krita) (account not yet created, seems to be based on open source gitlab solution)

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.

> [@Grum999](#):
>
> - If I made a merge request on [invent.kde.org/kde/krita](http://invent.kde.org/kde/krita), the result is also available on github?

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

> [@Grum999](#):
>
> - Is it possible to merge from current plugin [github repository](https://github.com/Grum999/Channels2Layers) or do I have to do it from scratch ?

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.

> [@Grum999](#):
>
> - What is recommended for the current plugin repository?  
> – Do I close the project?  
> – Do I let it alive?

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

> [@Grum999](#):
>
> - What’s the recommended workflow to update the plugin ?  
> – 1st update github repo and then ask for a merge to [invent.kde.org](http://invent.kde.org) ?  
> – Work directly with [invent.kde.org](http://invent.kde.org)?

The latter 🙂

---

<div class="post-metadata">

**Author:** ![raghukamath](https://krita-artists.org/user_avatar/krita-artists.org/raghukamath/32/59144_2.png) [@raghukamath](https://krita-artists.org/u/raghukamath)\
**Post date:** [April 14, 2020, 1:29pm UTC](https://krita-artists.org/t/channels-to-layers/5350/12 "2020-04-14T13:29:00Z")

</div>

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](https://docs.krita.org/en/untranslatable_pages/intro_hacking_krita.html#contributing-patches)

---

<div class="post-metadata">

**Author:** ![Grum999](https://krita-artists.org/user_avatar/krita-artists.org/grum999/32/66488_2.png) [@Grum999](https://krita-artists.org/u/Grum999)\
**Post date:** [April 14, 2020, 1:30pm UTC](https://krita-artists.org/t/channels-to-layers/5350/13 "2020-04-14T13:30:27Z")

</div>

Oh thanks!  
I’ll read it after work 🙂

Grum999

---

<div class="post-metadata">

**Author:** ![Grum999](https://krita-artists.org/user_avatar/krita-artists.org/grum999/32/66488_2.png) [@Grum999](https://krita-artists.org/u/Grum999)\
**Post date:** [April 14, 2020, 1:38pm UTC](https://krita-artists.org/t/channels-to-layers/5350/14 "2020-04-14T13:38:38Z")

</div>

> [@halla](#):
>
> 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.

I understand, it make sense 🙂

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

---

<div class="post-metadata">

**Author:** ![AhabGreybeard](https://krita-artists.org/user_avatar/krita-artists.org/ahabgreybeard/32/2969_2.png) [@AhabGreybeard](https://krita-artists.org/u/AhabGreybeard)\
**Post date:** [April 14, 2020, 2:30pm UTC](https://krita-artists.org/t/channels-to-layers/5350/15 "2020-04-14T14:30:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Grum999](https://krita-artists.org/user_avatar/krita-artists.org/grum999/32/66488_2.png) [@Grum999](https://krita-artists.org/u/Grum999)\
**Post date:** [April 14, 2020, 2:39pm UTC](https://krita-artists.org/t/channels-to-layers/5350/16 "2020-04-14T14:39:01Z")

</div>

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

Grum999

---

<div class="post-metadata">

**Author:** ![halla](https://krita-artists.org/user_avatar/krita-artists.org/halla/32/18581_2.png) [@halla](https://krita-artists.org/u/halla)\
**Post date:** [April 14, 2020, 2:50pm UTC](https://krita-artists.org/t/channels-to-layers/5350/17 "2020-04-14T14:50:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Grum999](https://krita-artists.org/user_avatar/krita-artists.org/grum999/32/66488_2.png) [@Grum999](https://krita-artists.org/u/Grum999)\
**Post date:** [April 14, 2020, 4:03pm UTC](https://krita-artists.org/t/channels-to-layers/5350/18 "2020-04-14T16:03:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![halla](https://krita-artists.org/user_avatar/krita-artists.org/halla/32/18581_2.png) [@halla](https://krita-artists.org/u/halla)\
**Post date:** [April 14, 2020, 4:30pm UTC](https://krita-artists.org/t/channels-to-layers/5350/19 "2020-04-14T16:30:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Grum999](https://krita-artists.org/user_avatar/krita-artists.org/grum999/32/66488_2.png) [@Grum999](https://krita-artists.org/u/Grum999)\
**Post date:** [April 17, 2020, 12:45pm UTC](https://krita-artists.org/t/channels-to-layers/5350/20 "2020-04-17T12:45:16Z")

</div>

@raghukamath @halla  
Ok, I created an identity for [invent.kde.org](http://invent.kde.org)

I’ve followed instruction provided:

> [@raghukamath](#):
>
> Not an answer to the questions, i just wanted to point you to the documentation regarding submitting patches - [Introduction to Hacking Krita — Krita Manual 5.2.0 documentation](https://docs.krita.org/en/untranslatable_pages/intro_hacking_krita.html#contributing-patches)

- Repository is forked ([Grum999 / Krita · GitLab](https://invent.kde.org/grum/krita))
- 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](http://invent.kde.org), I properly receive email to the defined email adress  
I also created and added a ssh keys (following [given instruction](https://invent.kde.org/help/ssh/README#generating-a-new-ssh-key-pair)) but it does not change anything… 😕

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

Grum999

[Next page](https://krita-artists.org/t/channels-to-layers/5350.md?page=2)
