Author Topic: Sort layer by size  (Read 1847 times)

GIMPel

  • Lives here ;-)
  • ***
  • Posts: 571
    • View Profile
Sort layer by size
« on: October 14, 2012, 06:18:25 pm »
Hello,

someone who already had such a task and wrote
a script for it?

Or someone who can give me a hint for writing this by myself?

Did the Plugin-API changed with introduction of layer groups?

GIMPel

GIMPel

  • Lives here ;-)
  • ***
  • Posts: 571
    • View Profile
Re: Sort layer by size
« Reply #1 on: October 14, 2012, 08:32:35 pm »
Hello,

someone who already had such a task and wrote
a script for it?

Or someone who can give me a hint for writing this by myself?

Did the Plugin-API changed with introduction of layer groups?

GIMPel

OK, I found out how to get the sizes of the layers.

How can I rearrange them in the layer stack?

Rolf

  • Administrator
  • Sr. Member
  • ***
  • Posts: 1887
    • View Profile
Re: Sort layer by size
« Reply #2 on: October 14, 2012, 09:03:38 pm »
The image has an array of layers. It should be possible to change them there.

Code: [Select]
temp = image.layer[0]
image.layer[0] = image.layer[1]
image.layer[1] = temp

or something like that. Not tried.....  ;-)

Edit: http://stackoverflow.com/questions/10221926/get-sublayers-from-group-layer-with-python-in-gimp has some pointers

GIMPel

  • Lives here ;-)
  • ***
  • Posts: 571
    • View Profile
Re: Sort layer by size
« Reply #3 on: October 14, 2012, 10:40:07 pm »
The image has an array of layers. It should be possible to change them there.

Code: [Select]
temp = image.layer[0]
image.layer[0] = image.layer[1]
image.layer[1] = temp

or something like that. Not tried.....  ;-)
[...]


Thanks... but I'm done before I read your answer ;-)

Some old scripts, people at gimp-irc and some docs did helped me to achieve it.

What looked like a big problem  turned out to be some lines of Python.
The most code that's left over is printing some helping information
that was needed in developing.
When I kick that out, it's less than about 90 lines.

Now I can go on with my picture I wanted to work on...


Now it has 125 lines...
« Last Edit: October 14, 2012, 11:06:50 pm by GIMPel »

Rolf

  • Administrator
  • Sr. Member
  • ***
  • Posts: 1887
    • View Profile
Re: Sort layer by size
« Reply #4 on: October 16, 2012, 01:44:56 pm »
.... and where is the code to peek at? ;-)

GIMPel

  • Lives here ;-)
  • ***
  • Posts: 571
    • View Profile
Re: Sort layer by size
« Reply #5 on: October 20, 2012, 10:24:15 pm »
.... and where is the code to peek at? ;-)

hmhhh.. what is the typical License that is used for Gimp-scripts?
GPL?

Edit: added more comments, so I'm close to 160 lines ;-)
« Last Edit: October 20, 2012, 10:41:59 pm by GIMPel »

Rolf

  • Administrator
  • Sr. Member
  • ***
  • Posts: 1887
    • View Profile
Re: Sort layer by size
« Reply #6 on: October 21, 2012, 04:02:51 pm »
GPL is the standard, but have a look here: http://www.codinghorror.com/blog/2007/04/pick-a-license-any-license.html . I like WTFPL very much too.

GIMPel

  • Lives here ;-)
  • ***
  • Posts: 571
    • View Profile
Re: Sort layer by size
« Reply #7 on: October 21, 2012, 10:03:09 pm »
Hello Rolf,

GPL is the standard, but have a look here: http://www.codinghorror.com/blog/2007/04/pick-a-license-any-license.html . I like WTFPL very much too.

I'm fine with GPL, but WTFPL also is funny :-)

To be honhest license issues are annoying, but....
...I did not invented this world, just have to cope with it.

So I chose GPLv3, which I also found in some other scripts ( I think rayadagio and mramshaw, some of the last threads in this subforum ), and thanks Rolf for your comment on the issue with the funny links.

So, here it is: Sort_Layers_by_size.

Please let me know what you (and others) think about it.
Does it offer usefulness to you?
Any other comments?

GIMPel

EDIT: just changed script after changing code to the better...
« Last Edit: October 21, 2012, 10:10:17 pm by GIMPel »