Filters as script in Ruby/Python/Whatever for Krita

Krita support scripts (in python and ruby) since 1.5 thanks to kross, but one things that was really missing (beside performance) was tighter integration with Krita, I mean, in 1.5/1.6, there is a docker with a list of scripts, and you click and it does ‘something’, but what I want is the ability to write filters, tools or anything else like in C++ but in Ruby (or in python if you really have to). The anything else part is mostly done if you use some Qt4 bindings, for instance it’s already possible to write a new docker in Ruby/Python and it will behave like a C++ plugin (I should try to write a color selector in ruby just for the fun of it). And now, it’s possible to write a filter which will appear like any other filter in Krita’s filter menu.

require 'Krita'
require 'KritaFilter'

def scriptProcess( src, srcTopLeft, dst, dstTopLeft, size, config )
 for i in 0...size[1]
  itSrc = src.createHLineConstIterator( srcTopLeft[0], srcTopLeft[1] + i, size[0] )
  itDst = dst.createHLineIterator( dstTopLeft[0], dstTopLeft[1] + i, size[0] )
  while (not itDst.isDone())

The only real drawback of this is the speed :/ But I am know we still have some room for improvements in the bindings, so not everything is lost, and if Krita provides enough high level primitives it shouldn’t be much of a problem, and then if someone likes to apply first a blur then a sharpness filter (in fact, that’s already possible since 1.5/1.6 but in a less cool way), he could create a filter script, and he wouldn’t notice the speed difference.

Now I need to do some polishing, and also to allow to get script tools.

This entry was posted in Krita, Open Source and tagged , , , . Bookmark the permalink.

2 Responses to Filters as script in Ruby/Python/Whatever for Krita

  1. Matthias says:

    What’s the size of the image chunks Krita uses when doing image operations or applying filters? Is 0.5MByte L2 Cache enough or would 1-2MB give better performance?

  2. Cyrille Berger says:

    For a rgb image, data is stored by 16KByte chunks. And when doing image operations it needs two chunks, for a total of 32KByte.That’s said, the more cache you have the better.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>