Writing Plugins for GIMP in Python - page 2
Creating a ScriptAll 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.
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.
- 1Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 2Linux Top 3: Linus Lashes out, Linux 3.14 Gets PIE and Ubuntu One is Done.
- 3Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 4Linux Top 3: RHEL 6.5, Debian 7.2 and EOL for Linux 3.0.x
- 5Linux Top 3: CoreOS, Oracle Enterprise Linux 7 and Ubuntu 14.10