This is the second time I try to get into Python scripting for GIMP. My script in the first show about scripting was simple, just saving some clicks. Now it is more complicated, variables, loops and floating points included. But no parrots!
You find a better version of the programs in the companion file. Following a tip in our Forum I included a Undo Group. So the action can be undone, a behaviour that should have been included from the start.
I mentioned some sources. Instant Python, the official Python Tutorial and the GIMP Python reference. Bert has a script page and a much better version of the Octave sharpening script.
Then we have a UnGIMP composition challenge on the Forum.
Have I forgotten some promised links? Please complain below!
The loop counter in the companion file is set to 6 instead of 4. You can change it back or leave it.
Perhaps it is better to take the image size from drw instead of img. See the discussion in the forum. drw.height and drw.width should work also when the layer is smaller than the image.