For gimp, the easy ways are figure out either python or scheme... for scheme there a re a number of pointers on the net.

Search for "script-fu"

I usually take one close and modify it.

-Rob A>