in reply to A little Gimp script

That's now how GIMP modules work: they are loaded by GIMP - and they are passed the image to work on.

If you want to work the other way (i.e. have modules choose the image to work on), then you should look at the Image::Magick modules.