Gimp, how can I find the positions of a layer?

I need to find the x / y positions for each layer. I’ve googled but I can’t find the answer.


You can use the python-fu console for that –
go to filters->python->console.
At the prompt, the first thing you need is to retrieve a reference to your
image of interst.

For example, typing img = gimp.image_list()[0] <enter> will store the reference to the most recently open image in the name img. If there is only one image open, that will be it. If you have several image, you may have to vary the “0” in the square brackets, until you get a reference to the desired image (hint: you can use the up arrow key to re-issue the command above, just changing the number).

You can see which image you’ve got in the img variable by checking is name: just type to see the images’ name if it has a matching .xcf file.

Once img points to your desired image, just type for layer in img.layers: print layer.offsets (and hit <enter> twice) – those are the x, y position for each layer, starting from the top-most layer.


>>> img = gimp.image_list()[0]
>>> for layer in img.layers: print layer.offsets
(94, 187)
(156, 70)
(0, 0)

(NB. the “>>>” and “… ” sequences are added automatically by the Python interpreter)

Source : Link , Question Author : Jules , Answer Author : jsbueno

Leave a Comment