Exporting Krita layers for use in Spriter

I’m currently working on a game where the characters are hand-painted in Krita (an amazing digital painting tool!). I’m then using Spriter (also awesome!) to put together 2d animations. My original workflow for getting the images from Krita to Spriter is very manual and error-prone, so I’ve put together an automated script to do it for me.

While Krita itself has the ability to save its layers as PNGs, it only works if the layers are all at the top-level, i.e. no nested layer groups. Since I’m working with 50+ layers, that would be painful! I tried just removing the layer groups every time I wanted to export, but that was almost as bad.

UPDATE: Originally, I was exporting to PSD, but the Krita developers got in touch and pointed out that .ORA files are really just zips. My updated workflow is to export as a .ORA file, then use a script to unzip them then manipulate with ImageMagick for the final resizing.

The script has to read the data from the stack.xml file, but it’s not as complicated as reading the PSD data using imagemagick.

Here is the updated script: