You pass an Image object -
Most of the parameters that are only integers in script-fu are not to be used - in their place, you have to pass an actual object reference. ANd how do you get those?
Simply all PDB functions and methods return these objects already - not their numeric IDs, like it happens in script-fu.
So, for Image, you either get the Image as parameter for your python-fu function, or on a call to pdb.gimp_image_new.
If, as it is often the case, you are making tests on the interactive console, you have to get references to the active images. In that case, call
gimp.image_list()
to get a Python list with the currently open images - the image at index 0 on this list is the rightmost (newest) open image on the screen -so just do image = gimp.image_list()[0]
to get a reference to it.
While you are at it, explore the image object with dir(image)
you willfind it is populated with attributes and methods that are handy shortcuts to otherwise hard-to-type pdb calls. For example, image.layers
gives you a Python list with reference to all layers on the image (as actual Layer objects, not their IDs), image.width
gives you the width, and calling img.new_layer()
creates a new layer and adds it to the image - this call has optional parameters to specify its name, width, height and so on.
As a last resort, there are reserved methods on the gimp
module that can convert a numeric ID to the actual objects: '_id2display', '_id2drawable', '_id2image', '_id2vectors'
- you should not need to use those. If you ever find your self needing to use those in the body of a script, due to some pdb function returning IDs instead of objects, please fill a bug report on GIMP's bugzilla.