RSS/Atom feed Twitter
Site is read-only, email is disabled

Plugin Development

This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

3 of 3 messages available
Toggle history

Please log in to manage your subscriptions.

Plugin Development Rob Antonishen 16 Jul 17:39
  Plugin Development Martin Nordholts 16 Jul 17:55
   Plugin Development Rob Antonishen 16 Jul 18:32
Rob Antonishen
2009-07-16 17:39:59 UTC (over 15 years ago)

Plugin Development

I have a (hopefully simple) question that I can not seem to find the answer for anywhere...

When is it appropriate to write:

- a script - a python plugin
- a compiled plugin

Specifically, If I have written a script and want better speed, should I write it as a python plugin, or as a C plugin?

Looking at the examples provided on C plugins (or at the code for these plugins themselves), they mostly seem to work at a low level, on a drawable/pixel. Would there be any advantage to a C plugin that just combines other PDB functions?

Here is an example. I want to make a drop shadow based on the alpha of a layer or a selection, with an offset, direction, colour and hardness....but want a preview for the user to see what their choices are doing. This could be done by pdb calls to duplicate layers, lock alpha, fill, blur, translate, etc. without having to access the pixel data of an image itself. I could do it with a script, but get no preview. I could do it with a python plugin, but still wouldn't get a preview (though I have read the the preview window widget is supported, I can't get it to work and have seen no example), or I could write it as a C plugin. But as a C plugin it would just be a bunch of calls to gimp_run_procedure? Does this make sense to do? Would any speed improvement be worth it?

Thanks in advance-

-Rob A>

Martin Nordholts
2009-07-16 17:55:30 UTC (over 15 years ago)

Plugin Development

On 07/16/2009 05:39 PM, Rob Antonishen wrote:

I have a (hopefully simple) question that I can not seem to find the answer for anywhere...

When is it appropriate to write:

- a script - a python plugin
- a compiled plugin

Specifically, If I have written a script and want better speed, should I write it as a python plugin, or as a C plugin?

The first thing you should do is to benchmark your current plug-in, what exactly is slow? The algorithm you use? Then switching language won't help. Is it the manipulation of individual pixels that is slow? Then switching to C might help as it enables you to be more clever about memory and CPU usage.

Looking at the examples provided on C plugins (or at the code for these plugins themselves), they mostly seem to work at a low level, on a drawable/pixel. Would there be any advantage to a C plugin that just combines other PDB functions?

No not that I can see, if all you do is invoke other procedures in the PDP, C is a bad language choice. One slight drawback of plug-ins written in Python is that it is not trivial to get Python working on a Windows install.

Here is an example. I want to make a drop shadow based on the alpha of a layer or a selection, with an offset, direction, colour and hardness....but want a preview for the user to see what their choices are doing.

The current script infrastructure is terrible for doing live previews, IMHO you should help getting GEGL integrated instead so that we can do this in a proper way.

This could be done by pdb calls to duplicate layers, lock

alpha, fill, blur, translate, etc. without having to access the pixel data of an image itself. I could do it with a script, but get no preview. I could do it with a python plugin, but still wouldn't get a preview (though I have read the the preview window widget is supported, I can't get it to work and have seen no example), or I could write it as a C plugin. But as a C plugin it would just be a bunch of calls to gimp_run_procedure? Does this make sense to do? Would any speed improvement be worth it?

Again, if all you do is invoke other procedures, C won't give you any notable performance improvement as most of the processing will occur in the GIMP core anyway.

HTH,

/ Martin

Rob Antonishen
2009-07-16 18:32:40 UTC (over 15 years ago)

Plugin Development

On Thu, Jul 16, 2009 at 11:57 AM, Martin Nordholts wrote:

On 07/16/2009 05:39 PM, Rob Antonishen wrote:

Specifically, If I have written a script and want better speed, should I write it as a python plugin, or as a C plugin?

The first thing you should do is to benchmark your current plug-in, what exactly is slow? The algorithm you use? Then switching language won't help. Is it the manipulation of individual pixels that is slow? Then switching to C might help as it enables you to be more clever about memory and CPU usage.

HTH,

 / Martin

Thanks, Martin. I that clarifies things for me a bit more.

Specifically, I wrote a script: http://registry.gimp.org/node/14051 that is quite slow as it does a lot of calls to gimp-selection-value to find a point "inside" a selection (using the gimp-selection-bounds results as the extents of the loop). So my though is a C (or even python?) implementation would be significantly faster.

-Rob A>