7

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

1 Answer 1

10

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 img.name 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.

Example:

>>> 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)

1
  • 1
    Seems list_images() has been renamed image_list()
    – Owen
    Commented Sep 9, 2017 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.