Home | Hardware | Internet News |Web Hosting |IT Management |Network Storage
LinuxPlanet
Search 
  Power Search | Tips 

 Front Door
 Discussion
 LinuxEngine
 Opinions
 Reports
 Reviews
 Tutorials
 News
 Technology Jobs

 Browse by subject.
Free Newsletter

Java/Open Source Daily
Linux Today
More Free Newsletters

Be a Commerce Partner


















internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Print this article
Email this article

   LinuxPlanet / Tutorials







Writing Plugins for GIMP in Python
Does it Register?

Akkana Peck
Wednesday, April 8, 2009 11:23:20 PM

Once you have your plug-in's skeleton in place, it's time to see if it registers right. Quit GIMP if it's already running, re-start it, and see if your plug-in shows up in the menu -- in this case, somewhere under Filters->Distorts (Figure 1).

Problems? If it doesn't show up, make sure your python script is executable, and try running gimp from the commandline. If there are any syntax errors in the script, it'll tell you. If no errors are being printed but your plug-in still isn't showing up, try gimp --verbose and watch to see if it's finding the script.

Writing the plug-in

Once you have your plug-in showing up in the menus, the rest is easy! Just call functions to do the same things you would have done yourself in GIMP. For this short article, let's do something very simple: flip the current image upside down.

How do you figure out how to do that? With the GIMP Procedure browser, available from GIMP's Help menu. In GIMP 2.4 and earlier it was in the Xtns menu inside the Toolbox window.

Open the Procedure Browser and search for flip (Figure 2).

There are a lot of different flip routines there; for now, let's pick one that looks simple, gimp-image-flip.

The Procedure Browser shows that it takes two parameters: the image to flip, and a flip-type that can be ORIENTATION-HORIZONTAL (0) or ORIENTATION-VERTICAL (1).

Here's how that translates into Python:

def python_pytest(img, layer) :
    pdb.gimp_image_flip(img, ORIENTATION_VERTICAL)

Make that change to your pytest file, and try it! No need to restart again -- once you've registered, GIMP knows where the file is and will pick up whatever changes you make. You only need to restart when you change something in the register() function.

So run Filters->Distorts->Py Test, and voilà! The image is flipped upside down (Figure 3). It's that simple.

In the next article, I'll show you how to use plug-in arguments to make a plug-in that does something much more useful.

Akkana Peck is a freelance programmer whose credits include a tour as a Mozilla developer. She's also the author of Beginning GIMP: From Novice to Professional.

« Back: Creating a Script

Skip Ahead

1 Creating a Script
2 Registering Your New Plugin
3 Does it Register?
Figure 1
Figure 1

Figure 2
Figure 2

Figure 3
Figure 3





Linux is a trademark of Linus Torvalds.


internet.com home | search | help! | about us

Jupiter Online Media

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers