Monday, July 23, 2007

Tegan's Tech Talk - GIMP Scripting Part One

Remember awhile ago when I started moaning about being unable to do batch scripting in GIMP? Well, I eventually got help and figured out what I was doing, and decided to write it up so I would remember it if/when I had to go back and do it again. Unfortunately, it's just not that easy to write up. So it's taken me quite some time to get around to it, and I'm not even positive I'm completely correct.

To make things even more interesting, I just got a real, legal copy of Photoshop, which I haven't even installed on my computer yet. I'm stunned to have it, and eager to start learning it (and incredibly grateful to the person who acquired it for me). But it makes me wonder if the effort of learning scripting in GIMP is worth documenting. However, I feel like if I took the effort to learn it, maybe I should try to hang onto that knowledge. So here goes...

This is REALLY esoteric, so most of you will want to stop reading about now.

To the rest of you, I'm not dumbing this down for you, I'm dumbing this down for me. I want to be able to understand this if/when I come back to it months from now. I really hope that this whole blog entry will be made obsolete by someone adding proper macro recorders and batching to GIMP. I'll point out that a start has been made by David's Batch Processor, which has some GIMP functions, but not all. The functions I needed weren't in DBP.

GIMP batch scripting is made up of two parts at the moment. Because this is open source software, the reality on the ground can and will change at a moment's notice, as some new developer adds something wonderful. This reflects reality as of Spring of 2007, when I first made a stab at GIMP scripting. Right, so to get back on track: GIMP batch scripting is made up of two parts.

The first part is writing a script in script-fu that will accept variables. The second is writing a batch file/shell script to run that script-fu. There's a tutorial here, but it doesn't help much if you simply don't know anything about it, which is where I started out. The same goes for this tutorial, which is missing the dead-simple stuff that newbies like me need. The guy who wrote the first tutorial came to my rescue, and now I understand most of the script.

Script-fu is the built in scripting tool in GIMP. It was designed by developers for developers, so it lacks the grace of a simple GUI for end users. However, it is actually very elegant and complete. What it offers is a way to access every function of GIMP via script. So if you want to rotate an image, you find the corresponding rotate piece in the script-fu and use that as your command. Yeah, it's a little more complicated than that, but basically anything you can do in GIMP using the GUI can also be done with a script, if you can figure out which script to call and feed it the right variables.

And that's what I'll do in part two... make myself a script-fu!

0 comments: