Writing Plugins for GIMP in Python - page 2
Creating a Script
All GIMP plug-ins, regardless of language, need to call register to tell GIMP they exist. Here's a skeleton of a GIMP-Python plug-in showing how to register. Copy and paste this into pytest so you can see how it works:
def python_pytest(img, layer) :
# Actual plug-in code will go here
return
register(
"python_fu_pytest",
"Does something",
"Does something terribly useful",
"Your name",
"Your name",
"2009",
"Py Test...",
"*",
[
],
[],
python_pytest,
menu="/Filters/Distorts")
main()
What does all that mean? The first part, def python_pytest, is the routine that will do the real work ... but for now, it's just a placeholder. It takes two arguments, the image and layer to work on. Any plug-in that modifies an existing image must use at least these two arguments. Plug-ins that create new images don't need them.
register is next. It takes quite a list of arguments:
- A python_fu name by which your function will be available to other GIMP scripts;
- Short and long descriptions of what the plug-in does;
- The name of the author and the copyright holder (usually the same person) and the copyright date;
- The name the plug-in should use in the menus;
- The types of images your plug-in can handle (RGB, greyscale, indexed or all). If it can work on any type of image, use "*"; if it creates a new image rather than operating on an existing one, use "";
- Any parameters the plug-in might show to the user -- I'll show how to use these in a future article;
- Any return values. Most python scripts leave this blank, or [];
- The name of the function that does the work, python_pytest;
- Where in the menus you want the function to show up.
Whew! Quite a lot of arguments, but usually you can copy most of them from some other plug-in and just change the values; you don't have to remember all of that.
- Skip Ahead
- 1. Creating a Script
- 2. Creating a Script
- 3. Creating a Script
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.