It is currently Thu Aug 20, 2026 2:26 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Request script - Change randomly Layers order
PostPosted: Sun Mar 17, 2013 8:40 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jul 21, 2012
Posts: 103
Hi to everyone, i've a crazy request.
I want change layers order automatically and randomly, there is a script or plug-in for this?
Thanks in advance.


Attachments:
a.png
a.png [ 3.83 KiB | Viewed 5643 times ]
b.png
b.png [ 4.01 KiB | Viewed 5643 times ]

_________________
Image


Last edited by d4rkheart on Sun Mar 17, 2013 5:45 pm, edited 1 time in total.
Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Request script - Change randomly Layers order
PostPosted: Sun Mar 17, 2013 12:43 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Nov 16, 2011
Posts: 5127
Location: Metro Vancouver, BC
If you have Gap or LayerGroups subsystem script you can do some interesting sorting.

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: Request script - Change randomly Layers order
PostPosted: Sun Mar 17, 2013 2:29 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
(define (script-fu-sg-shuffle-layers image)             
  (gimp-image-undo-group-start image)
  (let raise-loop ((layers (vector->list (cadr (gimp-image-get-layers image)))))
    (unless (null? layers)
      (let shuffle-loop ((i (random (length layers))))
        (when (> i 0)
          (set! layers (cons (car (last layers)) (butlast layers)))
          (shuffle-loop (- i 1)) ))
      (gimp-image-raise-layer-to-top image (car layers))
      (raise-loop (cdr layers)) ))
  (gimp-image-undo-group-end image)
  (gimp-displays-flush) )
 
(script-fu-register "script-fu-sg-shuffle-layers"
  "Shuffle layer stack"
  "Randomly change the position of layers in the layer stack"
  "Saul Goode"
  "saulgoode"
  "March 2013"
  "*"
  SF-IMAGE    "Image"    0
  )
(script-fu-menu-register "script-fu-sg-shuffle-layers"
  "<Image>/Image"
  )

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Request script - Change randomly Layers order
PostPosted: Sun Mar 17, 2013 5:30 pm  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jul 21, 2012
Posts: 103
@odinbc, thanks for your answer.
I've used gimp gap rarely, i don't know all its potentiality. With the script mig-gimp-layer-groups.scm i have encountered a lot of problems. The script returns an error or it isn't loaded if i don't move all scripts, that i have downloaded, in an other folder. :( :gaah I think that gimp doesn't tolerate many scripts
@saulgoode: :tyspin work well! Thank you so much.

I'm sorry for my bad translation. :oops:

_________________
Image


Top
 Post subject: Re: [SOLVED] Request script - Change randomly Layers order
PostPosted: Fri Mar 27, 2015 7:45 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Mar 27, 2015
Posts: 22
Hello kind coders,

Thanks for your generous coding and for making gimp so good.

This script works fine, however it starts to run very slowly when there are a lot* of layers.
Is it a recursive script? It's way beyond my crude scripting level.

If it is, is there a non-recursive solution?

Many thanks

*up to 10,000


Top
 Post subject: Re: [SOLVED] Request script - Change randomly Layers order
PostPosted: Fri Mar 27, 2015 8:04 pm  (#6) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Sweeney, please try the following version and see if it's any faster.

(define (script-fu-sg-shuffle-layers image)             
  (gimp-image-undo-group-start image)
  (let ((layers (cadr (gimp-image-get-layers image)))
        (len  (car (gimp-image-get-layers image))))
    (let loop ((cnt (* 3 len)))
      (unless (zero? cnt)
        (gimp-image-reorder-item image (vector-ref layers (random len)) 0 0)
        (loop (pred cnt)))))
  (gimp-image-undo-group-end image)
  (gimp-displays-flush) )

(script-fu-register "script-fu-sg-shuffle-layers"
  "Shuffle layer stack"
  "Randomly change the position of layers in the layer stack"
  "Saul Goode"
  "saulgoode"
  "March 2013" ; modified March 2015
  "*"
  SF-IMAGE    "Image"    0
  )
(script-fu-menu-register "script-fu-sg-shuffle-layers"
  "<Image>/Image"
  )

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: [SOLVED] Request script - Change randomly Layers order
PostPosted: Sat Mar 28, 2015 6:17 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Mar 27, 2015
Posts: 22
:clap Thanks, that's all good!


Top
 Post subject: Re: Request script - Change randomly Layers order
PostPosted: Fri Jun 24, 2016 9:24 am  (#8) 
Offline
New Member

Joined: Jun 24, 2016
Posts: 2
Oh wow I really would like to use this script, but I don't know how. I copied the code and saved it is an .scm file in my scripts folder, but I see nothing. Pardon my ignorance, but how do I use this?


Top
 Post subject: Re: Request script - Change randomly Layers order
PostPosted: Fri Jun 24, 2016 11:19 am  (#9) 
Offline
New Member

Joined: Jun 24, 2016
Posts: 2
I found it. Man I feel stupid.

It is under Image->Shuffle layer stack.


Top
 Post subject: Re: Request script - Change randomly Layers order
PostPosted: Fri Jun 24, 2016 6:14 pm  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jul 04, 2010
Posts: 2253
Location: Retired Moderator Slowly Returning to the Living.
It works perfectly!

_________________
Artists aren't crazy! We're eccentric! ~G.M. Ross

Image

My Sigs = My Photos
Check out my work at http://www.flickr.com/photos/photomastergreg.


Top
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group