GIMP Chat
http://gimpchat.com/

Batch Create Layers
http://gimpchat.com/viewtopic.php?f=8&t=18137
Page 1 of 1

Author:  RubisDrake [ Sat Mar 21, 2020 8:39 pm ]
Post subject:  Batch Create Layers

GIMP Version: 2.10.18
Operating System: Linux
OS Version: Ubuntu MATE
GIMP Experience: Intermediate Level



Hello all you lovely people,

I am looking for a way in GIMP (either with script-fu or python-fu) to batch create defined layers and layer groups in each of my image files in order to get rid of a bad habit of not using many layers. I am going through an exhausting process of "re-layering" my figure drawings in GIMP, and I was hoping to find a way to save some time.

I also would really like them to be "Default" layers, and not "Legacy", since I am using GIMP 2.10.18.

For example, let's say I want to make a tree of layers like this:

Layer "Sketch #1", linked, normal, opacity 65.0
Layer "Sketch #2", linked, normal, opacity 40.0
Layer "Sketch #3", linked, normal, opacity 25.0
Layer Group "Group #1", normal, opacity 65.0
+-- Layer "Group #1 Head", linked, normal, opacity 100
+-- Layer "Group #1 Ears", linked, normal, opacity 100
+-- Layer "Group #1 Eyes", linked, normal, opacity 100
+-- Layer "Group #1 Face", linked, normal, opacity 100
+-- Layer "Group #1 Arm Front", linked, normal, opacity 100
+-- Layer "Group #1 Arm Back", linked, normal, opacity 100
+-- Layer "Group #1 Hand Front", linked, normal, opacity 100
+-- Layer "Group #1 Hand Back", linked, normal, opacity 100
+-- Layer "Group #1 Body", linked, normal, opacity 100
+-- Layer "Group #1 Leg Front", linked, normal, opacity 100
+-- Layer "Group #1 Leg Back", linked, normal, opacity 100
+-- Layer "Group #1 Foot Front", linked, normal, opacity 100
+-- Layer "Group #1 Foot Back", linked, normal, opacity 100
Layer Group "Group #2", normal, opacity 100
+-- Layer "Group #2 Head", linked, normal, opacity 100
+-- Layer "Group #2 Ears", linked, normal, opacity 100
+-- Layer "Group #2 Eyes", linked, normal, opacity 100
+-- Layer "Group #2 Face", linked, normal, opacity 100
+-- Layer "Group #2 Arm Front", linked, normal, opacity 100
+-- Layer "Group #2 Arm Back", linked, normal, opacity 100
+-- Layer "Group #2 Hand Front", linked, normal, opacity 100
+-- Layer "Group #2 Hand Back", linked, normal, opacity 100
+-- Layer "Group #2 Body", linked, normal, opacity 100
+-- Layer "Group #2 Leg Front", linked, normal, opacity 100
+-- Layer "Group #2 Leg Back", linked, normal, opacity 100
+-- Layer "Group #2 Foot Front", linked, normal, opacity 100
+-- Layer "Group #2 Foot Back", linked, normal, opacity 100
Layer "Scenery FG", linked, normal, opacity 100
Layer "Scenery BG", linked, normal, opacity 100
Layer "Background", normal, opacity 100


So yeah, I need to do something like this in every unfinished drawing I have.

I want them to be able to be named, linked, and have their opacity set. Optionally, creating layer masks would be nice, but it is not a requirement. I usually create those if I need them on the fly.

Thank you so much for any help you can give!

Author:  Tas_mania [ Tue Mar 24, 2020 4:37 am ]
Post subject:  Re: Batch Create Layers

No takers eh?

I don't think you want a script to make content within new layers do you?
If you are not doing animation then all of your layers will have to be merged down for any sort of publication/printing.

A simple way of doing layer operations is just by using the keyboard.
EG. you can duplicate every layer by using the arrow up key and the duplicate button.
You can also copy and past layers to a new image with Ctrl-c and Ctrl-v
You can also copy whole layer groups to a new image by linking the group and then dropping the group into a new image at the layer you want it.

I use tims 'run code on visible layers' in python which is just a box you can paste python code into.
I have is set-up with this code: if layer.has_alpha: pdb.gimp_layer_flatten(layer)
Because I remove alpha from many layers often.

Author:  ofnuts [ Tue Mar 24, 2020 6:55 am ]
Post subject:  Re: Batch Create Layers

As answered elsewhere, the no-script solution is to prepare an XCF with the aforementioned layers, and add them to any image with "File>Open as layers".

If necessary the layers can be resized to fill the canvas with a script such as ofn-layers-to-image-size.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/