Contributing our batch sprites export plugin - need pointers

Nathan Lovato nathan at gdquest.com
Sun Jul 21 15:34:22 BST 2019


Hi,

I'm Nathan, also known as gdquest on the web. I make Krita tutorials 
from time to time: 
https://www.youtube.com/watch?v=qjUOdxP_L_s&list=PLhqJJNjsQ7KE3FLHIE31UgmLdcqsZfXTw

My teammate Razvan made an add-on to batch export layers flexibly. The 
tool can save lots of trimmed images for you, produce a clean folder 
structure, and scale the images on export. It uses metadata in the layer 
names.

We took inspiration from the export tools you can find in Sketch, 
affinity designer, and photoshop, and designed a tool adapted to Krita.

Here's the GitHub repository: https://github.com/GDquest/GDquest-art-tools/

Flexible batch export is something that we need as game developers, and 
that can also be of use to people making comics, doing graphic design, 
Web  design.

Thanks to Larpon, a contributor, you can also export your document for 
the Blender cut-out animation tools add-on, which allows you to do 
modular 2D animation for games.

I think it can be useful to many users and that's why we would like to 
contribute it so that it ships with Krita.

THE PROBLEM
=============

The code currently relies on the Pillow Python imaging library. The user 
needs to install a local version of Pillow in the add-on’s directory 
that matches their operating system. Right now, it’s a +/- manual process.

We use Pillow for a few reasons:

1. Resizing/scaling the image via Python starts an asynchronous process, 
but the function returns immediately. We couldn’t find a way to wait for 
the scale operation to finish before Krita calls Node.save() and exports 
the image. The only way we could solve this so far was using Pillow.
2. Pillow is fast. Using it makes export 2+x faster compared to using 
Krita’s built-in functions.

As a bonus, it’s a lot easier to manipulate the image with Pillow than 
using Krita’s API.

It's technically possible to automate the installation of the 
dependency, to have the right version of pillow bundled with Krita upon 
building the program.

A FEW QUESTIONS

About the add-on:

1. Is there a reliable way to transform the layer from Python with 
Krita, and wait for it to finish before saving the file?  If so we could 
remove Pillow as a dependency. (code contributions welcome!)
2. Would having pillow as a dependency be okay if we contributed the 
add-on? The library itself is sizeable, and it takes a good 6 megabytes 
on disk. For a single add-on, I bet it's too big but never hurts to ask. 🙂

Python add-on development with Krita:

3. Is there a way to reload Python plugins without closing and 
restarting Krita? Plugin dev is quite slow because of that right now.

Thank you for your time,
  Nathan



More information about the kimageshop mailing list