It is currently 17 Nov 2019, 07:13


GIMP/GL:  Tutorials | Tips | 🡆 Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

GIMP/GL QuestionsPython-fu loop trough layers

GIMP or GIMP LEARN forum related Questions
No avatar
JJ27182

Guests

Python-fu loop trough layers

Post#1 by JJ27182 » 23 Aug 2019, 14:20


I'm trying to place layers next to each other, let's say I have 2000x2000 picture and many 250x250 layers. For that, I'm trying to create a loop that goes trough all layers and relocates them, but I can't do this. I've tried several pieces of code, one example is here:

>>> import gimpfu
>>> img=gimp.image_list()[0]
>>> tasolista=pdb.gimp_image_get_layers(img)
>>> for t in tasolista[1]:
... pdb.gimp_image_select_item(img, CHANNEL_OP_REPLACE, t)
... pdb.gimp_layer_translate(t, 200, 200)
...
Traceback (most recent call last):
File "<input>", line 2, in <module>
TypeError: wrong parameter type

I used tasolista[1] instead of tasolista because I tried to print it and it said:
(4, (5, 4, 3, 2))
so I tought that actual layers might be in the latter, but I don't know if that's even right...
0 x

tim
GL Blogger

Post#2 by tim » 23 Aug 2019, 15:00


try this:

Code: Select all

img = gimp.image_list()[0]
layers = img.layers
for layer in layers:
    #do whatever you want with layer here
0 x
aka Tin
:tree_02:
Tin's: Favorite Index | Simple Art === fb4yt video search | fb4yt recent video views report
Lottery numbers from image | Interested Members in TLF
Paying for hosting is to support my hobby, and donating money made from ads to The Red Cross.
         


GIMP/GL:  Tutorials | Tips | 🡆 Questions | Interests | Script Requests
Recommendations:  Index | Top 10
Resources:  Python-Fu Plug-ins | Scheme-Fu Scripts | GIMP
Python:  Lessons | Questions | Exercises
The Arts:  GIMPed | GIMPed Photos | Other | Contests | Public Domain Images | Isolated Images | Blender
Inkscape
Social:  Say Hello | Anything Goes | Shares | FCSP

Post Reply
  • Similar Topics
    Replies
    Views
    Last post
• Featuring Members' Works (Image Attachments) •
1: member
2: member
3: member
4: member
5: member

Who is online

Users browsing this forum: No registered users and 10 guests