Edit layer in external application / run Photoshop plugin on layer

Hi! I’m new to the forum, and quite new to Krita. I’m an Adobe CS 6 refugee and since this year I have decided to move to Open Source software for my photography. However, I have some plugins in Photoshop that save me quite some time, that I would like to use. Fortunate for me, they can be used as stand-alone programs, but I quickly got tired of exporting a layer from Krita, starting the plug-in, edit, saving the file, and importing the modified layer into Krita again. So, I wrote a Krita plug-in that does that for me, and I’m here to share it. To be honest, I might have overlooked existing methods to do this, since I’m new, but then it was a good practice run with the Krita API.

Download

The plugin can be found here: Codeberg - Edit Layer Externally

After installing the plugin,you can find the script in the Tools/Scripts/Edit Layer Externally menu. On first use, the plug-in should ask you if you want to configure it. In case it doesn’t, or if you would like to reconfigure the external editor, use the Tools/Scripts/Configure Edit Layer Externally menu item. See below:

Configuring

First run the menu action Tools/Scripts/Configure Edit Layer Externally. Browse to an executable file with the file dialog that opens. If the executable needs any command line parameters or switches, you can add them in the dialog that opens after selecting a file. You can leave the box empty if no switches are required. Close the command line switch dialog with OK and the plugin is configured. You can reconfigure at any time by choosing Tools/Scripts/Configure Edit Layer Externally again.

Note: it is probably wise to not choose Krita itself as external editor, as that resulted in Krita hanging (on my Windows machine). Also, doesn’t make a lot of sense to choose Krita as editor, I guess.

Use

  • Select a paint/clone/file/group layer
  • Go to Tools/Scripts/Edit Layer Externally
  • Export the layer according to what your external editor needs
  • The external editor is opened. Modify what you need
  • Save over the temporary file
  • Close the external editor

Krita will load the external layer, and incorporate it in the document as a new layer above the source.

Notes

  • The plugin requires the file format to remain unchanged between saving and loading of the layer. For example, when working in a 16-bit integer environment, the layer is exported as a PNG. When saving, it should remain a PNG file.
  • The dimensions of the layer (width x height) can change, but the layer is not scaled upon import. The anchor point of the layer is the top left corner of the bounding box of the content.

I have only tested this on Windows 10 with Krita 5.2.5, and 8/16 bit RGB images mostly, though I had some success with the 32-bit floating point RGB format as well.

Feedback on performance on other platforms, but also on Windows is welcome!

Edit: I would like to thank the people in this thread, since it was very helpful to get started.

15 Likes

Hello @prutser and welcome to the forum :slight_smile:

Thank you for sharing this here.

1 Like

Thanks, and you’re welcome! :slight_smile:

1 Like

Thank you for sharing your work, @prutser. Welcome to the forum.

1 Like

Thank you! :slight_smile:

I’ve modified the Extension. Now it will save the external editor to the kritarc configuration file, instead of having it hard-coded into the Python file itself. Also, it now allows the user to configure the external editor at runtime, including any run time switches it might need, via a menu action.

1 Like

Hey, sounds cool.

I think you should just create a GitHub repo for the plugin, because that looks more legit than a random download link with just a zip.

In GH people can quickly skim through your code, read the readme, and better decide if they need the plugin. It will probably be more discoverable, too. You can upload it once and never touch it again. If it turns out you need to fix a bug or want to make an update it’ll be easier to manage.

3 Likes

Fair points, I’ve gone ahead and made a repo for it. See GitHub - rjmoerland/krita-edit-layer: A Krita plug-in that runs an external application on a single paint layer

Thanks for the feedback!

3 Likes

Hello @prutser,your plugin sounds very interesting.
My problem is that I am actually an idiot about even simple coding lines.
I still use Krita 5.1.5,because so far it works best for my need.
I have faced no problem installing your plugin & accessing the executable file (in my case ,that is Medibang pro),but it is asking to enter switches/run time options to add to the command line.
I have tried keeping it empty and hit okay option,but it’s not saving/registering the path.
So either it may not work in 5.1.5 or I need to add a command line dialogue.
I have no idea how to write/configure that line !

I can be totally wrong,but I felt probably your plugin can be similar like one available in the free software named Storyboarder.Where one can assign any single software as an additional editing software by selecting that exe file. After that a certain frame/layer can be edited inside that selected additional software and can achieve immediate updated result.

I found that option very helpful,because it helped me to use the best of both softwares at the same time.
Is your plugin works something similar like this or I have got it all wrong ?!

UPDATE: After a little trial and error method,the plugin statred to function as said,but I guess probably there are some compatibility issues between krita and softwares like medibang,firealpaca or paint tool sai.So the layers don’t get imported properly and sometime it freezes.
As I don’t use PS anymore, my options are short now !
But that is not fault of your plugin :slight_smile: !
Thank you for creating such an interesting plugin and maybe someday in future things will improve for me .

1 Like

Hi @ari, I’ve looked into this and it seems that the colors are wrong (blue and red swapped) if you would use 8-bit images. I’ve updated the plug-in to fix this, if you’d like to try again :slight_smile:
Just download a new copy of the zip file and install it as usual.

I’m not very familiar with the applications you mentioned, as I don’t use Krita for painting myself (:shushing_face:), but I did manage to get a working setup with MediaBang & Krita 5.2.3

1 Like

Thanks for the prompt reply @prutser .
As per your suggestion,this time I have installed the latest portable version of Krita(5.2.3) and also the latest version of your plugin.
This time the installation and the configuring part went absolutely smooth.
But when the layer opened up in Medibang pro,it went black.
Here is a glimpse of what happened.

After some rethinking,I felt maybe this was happening because I am using a transparent layer. So as a last resort, I used an opaque layer and it was a complete success :smile: !
So probably your plugin currently doesn’t support transparent layers.
Please let me know if again I am doing something wrong here !
Thanks again for the help .

Good to hear there is progress! The plug-in should be able to handle transparent layers. Here’s a quick result from my experiment:

In Krita (note the top layer has transparency):

It turns up like this in MediaBang for me:

That seems to indicate transparency. You do need to have the Store Alpha channel (Transparency) option checked while exporting, if that isn’t the case.

Now, your video is enlightening: it seems that the export dialog box is completely skipped for some reason. I have encountered this as well during development, but I have not seen it for a while. I’m not sure why that happens…

While doing this exercise, I noticed that alpha channels in 8 bit mode were handled in a weird way, leading to artifacts in the layer once it was loaded back into Krita. Therefore, I’ve tried a completely different approach, that works well on my machine. If you would like to try if this works better for you, here a link to the zip archive: Microsoft OneDrive

Edit: alternatively, you can download the plug-in from GitHub again, but with a different branch as source: GitHub - rjmoerland/krita-edit-layer at alternative-reimport-method

1 Like

Hello @prutser.
Yes,I can see that transparent layers are working in your example.
As suggested,I have installed the latest version of your plugin.
But sadly even with that latest plugin, currently the transparent layers are not working for me.
With that it seems I am also facing problem in saving the updated layer.
Here’s what happened :-

  1. Selected Paint tool sai as the software,the configuration process worked flawlessly.

  2. but not able to open or display transparent or opaque layers.

  3. Changed the software to Medibang pro and again the configuration process worked flawlessly.

  4. Not able to import the transparent layer.

  5. Made the same layer opaque and imported again.

6)This time it was imported properly inside Medibang pro.

  1. Added few lines and tried to save the modified image inside Medibang pro.

  2. Not able to save it and in the end Krita started to stop responding.

Here is the video

  1. Tried the same procedure with a fresh file.

  2. Imported an opaque file again inside medibang pro .

  3. It opened successfully,but with a warning box”file does not exist”.

  4. Added few red lines and tried to save ,but not able to save.

I will try out few more approaches in coming week.
Let’s see if I can find my own way to make it work !
But thanks for all the help :slight_smile: !

1 Like

The video is slightly too quick for me too be able to judge, but in case you didn’t: the application you use to edit the layer needs to be closed in order to update the layer in Krita. Krita will be unresponsive until you do so. Does that help?

Sorry about the quick video,but krita community supports video size only up to 3 mb.
So had to make it short somehow,but I can understand your problem.

My problem is that I am not getting the chance to save the updated image inside the external editor (please check the attached images(Step 9-12) in my last feedback).
But are you saying it should be like this : -
I add few modifications inside the external editor,then use the save option inside the external editor ((which is not working for me),then close down the whole external editor and move back to krita,where the new duplicate layer will be automatically updated ?

Don’t get me wrong, the videos are providing a lot of insight, I’m thankful for the fact that you take the time to create them!

But are you saying it should be like this […]

That’s indeed how in theory it should work. I’ll try MediaBang again, to be sure. I’ll try to work out what the issue might be with saving. I’ve added debug statements to the code of the plug in. It might be helpful to get the log of these while you use the plug-in. You can view them by showing the Log docker (you need to enable logging explicitly, see the previous link)

Thanks for guiding me here !
I am attaching the log result here (let’s hope I have done it right).
By the way,the log result came in yellow colour.
Just added that small information,in case if it’s significant .

The first one done with transparent layer and the last one with opaque.

Node::setPixelData: not enough data to write to the paint device
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
Node::setPixelData: not enough data to write to the paint device
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
WARNING: the destination object of KisSynchronizedConnection has been destroyed during postponed delivery
KoFileDialog::onFilterSelected: Cannot find suffix for filter “”

I always faced a strange problem of PSD compatibility problem between Medibang pro and Krita.

For the first time they both support each other in psd format.

Ex- I create a psd file in Krita and try to open the same in medibang.
It will open without any issue,after that save it as PSD again and try to open in Krita…
and suddenly it becomes unreadable.
Same thing happen in the opposite process !
So maybe some answers can be hidden there also .

My apologies, indeed you are right and the alternative method does not work.

Then the original method remains the best option, but it doesn’t handle alpha channels well. In my test cases, I see color artifacts appear after reloading the edited layer into Krita. I’m thinking the distinction between straight alpha and pre-multiplied alpha is the root cause, but I need more time to investigate how to fix things if that’s the case.

1 Like

Hi @ari ,
I think (:crossed_fingers:) I have found a workflow that works with Krita and MediBang, with transparency supported. You’ll need the latest version of the plugin, available from GitHub (see link in top post). Then, what worked for me with fresh installs of Krita 5.2.3 and MediBang:

Let me know how this goes!

1 Like

Fantastic work @prutser :smile: !!
Though it is bypassing the png export setting box in Krita and automatically configuring the png setting ,but I have no problem with that !
Because now it’s working so smoothly !

Thank you so much for helping out !

1 Like