Difference between revisions of "Hacking:Plugins"

From GIMP Developer Wiki
Jump to: navigation, search
(Created page with 'GIMP supports [http://en.wikipedia.org/wiki/Plug-in_%28computing%29 plug-ins]. Some plug-ins are distributed with GIMP and some are distributed by third parties. == Plug-ins a…')
 
Line 3: Line 3:
 
Some plug-ins are distributed with GIMP and some are distributed by third parties.
 
Some plug-ins are distributed with GIMP and some are distributed by third parties.
  
 +
 +
== Getting Started ==
 +
 +
A good way to get started is to read plug-ins distributed with GIMP.
 +
 +
You can test snippets of Scheme and Python plug-ins on the consoles available in GIMP at the menu items: Filters>Script-Fu>Console and Filters>Python-Fu>Console.  A console is a terminal window that lets you enter and execute statements in the programming language.
 +
 +
The documentation for the PDB is available in GIMP at the menu item: Help>Procedure Browser.
  
 
== Plug-ins and the GIMP Procedural DataBase (PDB) ==
 
== Plug-ins and the GIMP Procedural DataBase (PDB) ==
  
Plug-ins must register themselves in the PDB.  Other GIMP functions, called internal procedures, are also in the PDB.
+
Plug-ins must register themselves in the PDB.  Other GIMP functions, called internal procedures, are also in the PDB.  An internal procedure often provides a function also found in the GIMP menus.
 +
 
 +
Registration means declaring the name and parameters of a plug-in, as well as declaring where a plug-in will appear in the GIMP menus, if at all.
 +
 
 +
A plug-in commonly calls other plug-ins in the PDB.
  
 
== Programming Languages for GIMP Plug-ins ==
 
== Programming Languages for GIMP Plug-ins ==
Line 14: Line 26:
 
C language GIMP plug-ins are compiled and linked with Gimp libraries.  They can access functions in those libraries or functions in the PDB.  They are distributed as executable files with suffix ".exe".
 
C language GIMP plug-ins are compiled and linked with Gimp libraries.  They can access functions in those libraries or functions in the PDB.  They are distributed as executable files with suffix ".exe".
  
Scheme language GIMP plug-ins are interpreted.  They can access procedures in the GIMP Procedural Database (PDB.)  They are distributed as text files called scripts with suffix ".scm".
+
Scheme language GIMP plug-ins are interpreted.  They can access procedures in the GIMP Procedural Database (PDB) as well as the functions built into the Scheme language.  They are distributed as text files called scripts with suffix ".scm".
 
+
Python language GIMP plug-ins are interpreted.  They can access procedures in the GIMP Procedural Database (PDB) as well as functions provided by the PyGimp set of Python modules (chiefly, the module named "gimpfu".) They are distributed as text files with suffix ".py".
+
  
 +
Python language GIMP plug-ins are interpreted.  They can access procedures in the GIMP Procedural Database (PDB) as well as functions provided by the PyGimp set of Python modules (chiefly, the module named "gimpfu") and functions provided by the Python modules in a standard Python distribution.  They are distributed as text files with suffix ".py".
  
 
== Choosing a Language for a GIMP Plug-in ==
 
== Choosing a Language for a GIMP Plug-in ==
Line 23: Line 34:
 
Plug-ins are usually usually written in the C language if they implement fundamental algorithms at the pixel level.  Such plug-ins might need the speed of a compiled language and full access to the GIMP libraries.  However, such plug-ins need to be separately compiled for each platform.
 
Plug-ins are usually usually written in the C language if they implement fundamental algorithms at the pixel level.  Such plug-ins might need the speed of a compiled language and full access to the GIMP libraries.  However, such plug-ins need to be separately compiled for each platform.
  
Plug-ins written in Scheme or Python usually implement  
+
Plug-ins written in Scheme or Python usually implement less compute intensive algorithms.  Often they implement recipes: step-by-step sequences of actions a user could do manually using the GIMP.  They are limited to GIMP functions found in the PDB (they can't directly access the Gimp C libraries.)  They are very portable (assuming the separate Python interpreter is installed.)
  
 +
Plug-ins in C can provide any user interface using, for example, the GTK toolkit.  Plug-ins written in Scheme or Python can easily provide a dialog for plug-in settings using a standard set of widgets provided (by the Scheme interpreter and the PyGimp modules) for the parameters of the plug-in.  Plug-ins written in Python can provide fuller user interfaces by using, for example the PyGTK toolkit, which is in a standard Python distribution.
  
== Tutorials on Programming GIMP Plug-ins ==
+
C is an older language, the traditional programming language for systems level programming with full access to the underlying hardware and operating system.  It is powerful but unforgiving.
 +
 
 +
Scheme is a Lisp-like language with a very simple syntax.  Some people find it hard to learn and difficult to read.  The set of functions distributed with the Scheme interpreter built into Gimp is what the language provides, so you might need to include third party Scheme functions inside your plug-in.
 +
 
 +
Python is a more recent language.  It supports programming concepts such as object orientation and exceptions.  Since it is interpreted, it supports agile programming or rapid prototyping.  Most Python programs are written idiomatically, using common phrases.  Some people find Python abstractions and idioms difficult to learn.  The set of modules in a standard Python distribution provides a rich set of components.
 +
 
 +
 
 +
== Community of GIMP Plug-in Authors ==
 +
 
 +
Many authors of GIMP Scheme and Python plug-ins lurk at:
 +
 
 +
[http://registry.gimp.org/ Gimp Plugin Registry]
 +
 
 +
[http://www.gimptalk.com/ Gimptalk]
 +
 
 +
Generally, there are fewer authors of C-language GIMP plug-ins.  The community of GIMP developers are mostly C programmers but they don't often write plug-ins.  Questions to GIMP developers concerning C-language plug-ins are discouraged for all but difficult questions.  Bugs in third-party plug-ins (those not distributed with GIMP) should NOT be reported as GIMP bugs, only reported to the author or maintainers of the third-party plug-ins.
 +
 
 +
== References for Programming GIMP Plug-ins ==
 +
 
 +
[http://developer.gimp.org/plug-ins.html A tutorial on programming GIMP plug-ins in the C language.]
  
 
[http://www.gimp.org/docs/scheme_plugin/ A tutorial on programming GIMP plug-ins in the Scheme language.]
 
[http://www.gimp.org/docs/scheme_plugin/ A tutorial on programming GIMP plug-ins in the Scheme language.]
 +
 +
[http://www.gimp.org/docs/python/index.html GIMP Python Documentation.]
 +
 +
[http://www.ibm.com/developerworks/opensource/library/os-autogimp/index.html#resources A tutorial on programming GIMP plug-ins in Python.]

Revision as of 20:08, 23 May 2011

GIMP supports plug-ins.

Some plug-ins are distributed with GIMP and some are distributed by third parties.


Getting Started

A good way to get started is to read plug-ins distributed with GIMP.

You can test snippets of Scheme and Python plug-ins on the consoles available in GIMP at the menu items: Filters>Script-Fu>Console and Filters>Python-Fu>Console. A console is a terminal window that lets you enter and execute statements in the programming language.

The documentation for the PDB is available in GIMP at the menu item: Help>Procedure Browser.

Plug-ins and the GIMP Procedural DataBase (PDB)

Plug-ins must register themselves in the PDB. Other GIMP functions, called internal procedures, are also in the PDB. An internal procedure often provides a function also found in the GIMP menus.

Registration means declaring the name and parameters of a plug-in, as well as declaring where a plug-in will appear in the GIMP menus, if at all.

A plug-in commonly calls other plug-ins in the PDB.

Programming Languages for GIMP Plug-ins

GIMP plug-ins are written in the C, Scheme, Python, or Perl programming languages.

C language GIMP plug-ins are compiled and linked with Gimp libraries. They can access functions in those libraries or functions in the PDB. They are distributed as executable files with suffix ".exe".

Scheme language GIMP plug-ins are interpreted. They can access procedures in the GIMP Procedural Database (PDB) as well as the functions built into the Scheme language. They are distributed as text files called scripts with suffix ".scm".

Python language GIMP plug-ins are interpreted. They can access procedures in the GIMP Procedural Database (PDB) as well as functions provided by the PyGimp set of Python modules (chiefly, the module named "gimpfu") and functions provided by the Python modules in a standard Python distribution. They are distributed as text files with suffix ".py".

Choosing a Language for a GIMP Plug-in

Plug-ins are usually usually written in the C language if they implement fundamental algorithms at the pixel level. Such plug-ins might need the speed of a compiled language and full access to the GIMP libraries. However, such plug-ins need to be separately compiled for each platform.

Plug-ins written in Scheme or Python usually implement less compute intensive algorithms. Often they implement recipes: step-by-step sequences of actions a user could do manually using the GIMP. They are limited to GIMP functions found in the PDB (they can't directly access the Gimp C libraries.) They are very portable (assuming the separate Python interpreter is installed.)

Plug-ins in C can provide any user interface using, for example, the GTK toolkit. Plug-ins written in Scheme or Python can easily provide a dialog for plug-in settings using a standard set of widgets provided (by the Scheme interpreter and the PyGimp modules) for the parameters of the plug-in. Plug-ins written in Python can provide fuller user interfaces by using, for example the PyGTK toolkit, which is in a standard Python distribution.

C is an older language, the traditional programming language for systems level programming with full access to the underlying hardware and operating system. It is powerful but unforgiving.

Scheme is a Lisp-like language with a very simple syntax. Some people find it hard to learn and difficult to read. The set of functions distributed with the Scheme interpreter built into Gimp is what the language provides, so you might need to include third party Scheme functions inside your plug-in.

Python is a more recent language. It supports programming concepts such as object orientation and exceptions. Since it is interpreted, it supports agile programming or rapid prototyping. Most Python programs are written idiomatically, using common phrases. Some people find Python abstractions and idioms difficult to learn. The set of modules in a standard Python distribution provides a rich set of components.


Community of GIMP Plug-in Authors

Many authors of GIMP Scheme and Python plug-ins lurk at:

Gimp Plugin Registry

Gimptalk

Generally, there are fewer authors of C-language GIMP plug-ins. The community of GIMP developers are mostly C programmers but they don't often write plug-ins. Questions to GIMP developers concerning C-language plug-ins are discouraged for all but difficult questions. Bugs in third-party plug-ins (those not distributed with GIMP) should NOT be reported as GIMP bugs, only reported to the author or maintainers of the third-party plug-ins.

References for Programming GIMP Plug-ins

A tutorial on programming GIMP plug-ins in the C language.

A tutorial on programming GIMP plug-ins in the Scheme language.

GIMP Python Documentation.

A tutorial on programming GIMP plug-ins in Python.