background preloader

Plug-in Development

Facebook Twitter

Developer Resources - How to write a GIMP plug-in, part II. Written By Dave Neary In the first part, I presented essential elements to build a plug-in interface with The GIMP. Now we will produce a simple but useful algorithm that we could use in our plug-in. The algorithm we are going to implement is a simple blur. It is included in The GIMP as "Filters->Blur->Blur" with default parameters. That algorithm is very simple. Each pixel in our image is replaced by a mean value of its neighbours. With this method, edge differences are splatted, giving a blurred result. Last month, we wrote a run() function that did nothing useful. Static void run (const gchar *name, gint nparams, const GimpParam *param, gint *nreturn_vals, GimpParam **return_vals); We saw that for a filter (i.e. a plug-in that modifies the image), the first three input parameters were the run mode, an identifier for the image, and another one for the active drawable (layer or mask).

Drawables To get a GimpDrawable from its identifier, we need the gimp_drawable_get() function: Tiles. Python Documentation. This document outlines the interfaces to GIMP-Python, which is a set of Python modules that act as a wrapper to libgimp allowing the writing of plug-ins for GIMP. In this way, GIMP-Python is similar to Script-Fu, except that you can use the full set of Python extension modules from the plug-in. Introduction What is it? GIMP-Python is a scripting extension for GIMP, similar to Script-Fu. The main difference is in what is called first. In Script-Fu, the script-fu plug-in executes the script, while in GIMP-Python the script is in control. In fact, you will find that the GIMP-Python scripts start with the line !

Another point of difference between GIMP-Python and Script-Fu is that GIMP-Python stores images, layers, channels and other types as objects rather than just storing their ID. Also, GIMP-Python is not limited to just calling procedures from the PDB. Installation GIMP-python consists of a Python module written in C and some native python support modules. .

The Structure Of A Plug-in #! Data.

PyGimp

Writing a GIMP Plug-In. Developer Resources - Plug-In Development. Developer Resources - How to write a GIMP plug-in, part III. Written By Dave Neary In the second part, I told you about manipulating image data by pixel or row. This time, I will go farther and process data by tile, which will improve our plug-in performance. I will also update our algorithm to take larger radius into account, and build a graphical interface to allow changing that parameter. Let's have a look at our simple algorithm: for each pixel, generate a (2r+1)x(2r+1) neighbourhood and for each layer, replace the layer's pixel value with the average value in the neighbourhood.

It's a bit more complex than that - we have to be careful near image borders for example, but this algorithm makes a blur effect that is not so bad in general. But until now, we wrote the algorithm for a 3x3 neighbourhood. Time has come to generalise this part and to introduce the radius as a parameter. First, a word on tiles. A tile is an image data block with a 64x64 size.

Gimp_tile_cache_ntiles (gulong ntiles); With the cache, our slow plug-in becomes fast. Glade tree. Developer Resources - How to write a GIMP plug-in. Written By Dave Neary In this article, I present GIMP plug-ins basics and introduce the libgimp API. I will also show how to use the PDB to make our plug-in available to other script authors. New developers are often intimidated by The GIMP size and its reputation. They think that writing a plug-in would be a difficult task. The goal of these articles is to dumb this feeling down, by showing how easily one can make a C plug-in. In this part, I present a plug-in's basic elements. Architecture The GIMP script interface is centered on the Procedural database (PDB). The plug-in declares itself to the PDB at that time, and passes informations like the position it wishes to get in the menu hierarchy, input parameters, and output parameters. When a script or a plug-in wants to use our plug-in, it gets through the PDB, which manages communicating parameters in one direction and the other in a transparent way.

Syntax is gimptool-2.0 --install plugin.c or gimptool-2.0 --install-admin plugin.c.

Script-Fu