Home > Krita, Open Source > Filters as script in Ruby/Python/Whatever for Krita

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())
   itDst.copyFrom(itSrc)
   itDst.invertColor()
   itSrc.next()
   itDst.next()
  end
 end
end

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.

Advertisements
  1. Matthias
    5 June, 2007 at 20:41

    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
    5 June, 2007 at 21:17

    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.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: