Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

Multiple Layer Actions Script Rel5.1 [Added 'Center All Layers']

Wed Jan 01, 2014 11:37 pm

This script will combine many of the functions done by Fenceposts all layers scripts with a lot of new features and more to be added, Thanks to GnuTux for conceiving the idea,
This Script is for 2.8 only at present
If anybody would like to contribute ideas for additional actions please let me know

There are 3 types of layers to effect
"All layers"
"Linked Layers"
"Non-Linked Layers"

At the moment there are 13 actions
"Set Invisible"
"Set Visible"
"Invert"
"Clear Selection"
"Layer to Image Size"
"Semi-Flatten"
"Flatten"
"Add Alpha"
"Remove Layers from Image"
"Desaturate"
"Colorify"
"Color Balance"
"AutoCrop Layers"
"Center All Layers"

More actions will be added soon


Image
Menu Location Layer/Multiple Layer Actions

; Rel 0.02 - Bugfix for Layers with Locked Pixels, Added additional actions 'Clear Selection' and 'Layer to Image Size'

; Rel 0.03 - Enabled layer group functionality

; Rel 0.04 - Added Additional Actions

; Rel 0.05 - Added Actions for Color: Desaturate, Colorify and Color Balance

; Rel 05.1↓ - Added Additional Actions

Download From Gimp Scripts

Re: Multiple Layer Actions Script

Thu Jan 02, 2014 2:06 am

Is there something that would clear a selection on all layers. If not maybe this could be added.

Re: Multiple Layer Actions Script

Thu Jan 02, 2014 2:42 am

Set all visible/invisible is quicker to do with Shift-click on eye icon,
color inversion on all layers...idk who'd need that
sorry missed the linked/non-linked part

my candidates for your script:

all layers to image size
add alpha channel to all layers
merge linked layers
delete linked layers

...just a few useful ops i can think of...

also ditto to what Wallace suggested

Re: Multiple Layer Actions Script

Thu Jan 02, 2014 2:50 am

Script doesn't execute (error message) if there is a layer(s) with locked pixels or locked transparency,
can you make your script ignore locked layers, Graechan?

thanks

Re: Multiple Layer Actions Script

Thu Jan 02, 2014 4:12 am

Wallace wrote:Is there something that would clear a selection on all layers. If not maybe this could be added.


See clear-layers here : https://sourceforge.net/projects/gimp-t ... s/scripts/ :)

This said there is a limit to this kind of script... either you can only have function without parameters, or you end up redoing parameter entry dialogs for every tool you use. Or you have some clever code that can read the PDB, discovers the parameters and generates a dialog on the fly...

Re: Multiple Layer Actions Script

Thu Jan 02, 2014 9:49 am

Thanks for putting this together, Graechan. It's a good starting template.

I'd like to see the following added.
Horizontal & Vertical Flip
Semi-Flatten
Rotate 90 Clockwise & Counter Clockwise
Layer to Image size

Re: Multiple Layer Actions Script

Thu Jan 02, 2014 3:13 pm

I'd also like to see "Colorize all layer", with an option to colorize only visible layers.

Re: Multiple Layer Actions Script

Thu Jan 02, 2014 4:27 pm

Back when I wrote my Combine BG script, I remember working on a similar concept. I started with the idea that the paste buffer could be used to hold the layer that was to be combined and so the command would be either "Paste" or "Paste Behind" to Overlay or Combine with each of the targeted layers.

This did not work out very well because the paste buffer gets centered relative to the target layer when pasting, resulting in the pasted image "moving" around unless all of the layers were the same size and in the same location. I then added a way to resize all of the layers to the image size but this only offered a partial solution -- the pasted image no longer moved around but unless the paste buffer contained an image-sized graphic, the position would still be centered in the image. Basically the paste buffer approach was a dead end.

Nonetheless, at the time I had written this, my script expanded to support several different operations on multiple layers, not just pasting and resizing. However, I did this in a way that fits my own quirky thought processes to which many might object. Mainly, I did not want to have special options that could be accomplished by just running the script additional times. For example, hiding a set of layers would entail showing the layers and then toggling their visibility; or rotating layers counter-clockwise could be accomplished by rotating clockwise and then pressing CTRL-f twice. I think this approach might still has merit, especially if you start getting into dozens of operations.

Here are the options I'd provided:
Code:
    SF-OPTION "Limit to" '( "All layers"
                            "Visible"
                            "Linked"
                            "Above active"
                            "Below active" )
    SF-TOGGLE "Include Active Layer" TRUE         
    SF-OPTION "Operation" '( "Do nothing"
                             "Add alpha channel"
                             "Autocrop"
                             "Layer to image size"
                             "Clear selected"
                             "Paste"
                             "Paste behind"
                             "Apply layer mask"
                             "Flip"
                             "Rotate 90" )
    SF-OPTION "Disposition" '( "Unchanged"
                               "Set visible"
                               "Set linked"
                               "Toggle visibility"
                               "Toggle linkage" )


For whatever it's worth, here is the link to the script I wrote (it did not, of course, support layer groups). I also recall making a later version that copied the active layer's blend mode or opacity to the target layers, but I can't locate the code for that.

PS: Not to be a grammar nazi, but your first option should be titled "Layers to Affect", not "Layers to Effect".

Re: Multiple Layer Actions Script

Thu Jan 02, 2014 7:08 pm

K1TesseraEna thank you for finding that oversight I made, it wont be an issue in the next release
What to do with layer groups worries me, as I don't understand how to work within them

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Thu Jan 02, 2014 8:38 pm

Rel2 has been added, see initial post
; Rel 0.02 - Bugfix for Layers with Locked Pixels, Added additional actions 'Clear Selection' and 'Layer to Image Size'

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Thu Jan 02, 2014 9:07 pm

I agree with Tux this makes for a great template to add actions or processes to layers. Colorize would be a real great option to add perhaps as it was added to Blue Ice but on linked, un-linked, visible, and non visible layers/selections.
Selection to all other linked, non-linked, visible, non-visible layers would be great also.

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Thu Jan 02, 2014 9:22 pm

Thanks Rod in Rel2 I've added a preconditions section to the script

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Thu Jan 02, 2014 9:26 pm

Graechan wrote:
Thanks Rod in Rel2 I've added a preconditions section to the script


Great script Graechan and thank you. :)

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Fri Jan 03, 2014 11:49 am

Thank you for the script G!
Keep holding my breath for more added functions!

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Fri Jan 03, 2014 3:25 pm

I don't see the added actions & I downloaded the update.

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Fri Jan 03, 2014 11:34 pm

Huston I have a problem as the script deals with layer lists that are created and if any of these have a layergroup ID it fails,
I've tried (if (= (gimp-item-is-group layerId) FALSE) (gimp-invert layerId)) among many other things

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Sat Jan 04, 2014 1:05 am

So to run the script on any layers they would have to be un-grouped and then re-grouped perhaps? :)

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Sat Jan 04, 2014 1:24 am

Rod That restriction on a script seems 2 severe there, must be a solution to this dilemma and I hope Saulgoode can help (the master is looking at it now).
A solution will assist us all in future scripts

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Sat Jan 04, 2014 2:02 am

Awesome. :)

Re: Multiple Layer Actions Script Rel2 [bugfix and more actions]

Sat Jan 04, 2014 5:27 am

Graechan wrote:Huston I have a problem as the script deals with layer lists that are created and if any of these have a layergroup ID it fails,
I've tried (if (= (gimp-item-is-group layerId) FALSE) (gimp-invert layerId)) among many other things


Try to replace the statement you proposed, that is:
(if (= (gimp-item-is-group layerId) FALSE) (gimp-invert layerId))

with this one:
(if (= (car (gimp-item-is-group layerId)) FALSE) (gimp-invert layerId))
Post a reply