11-25-2022, 08:10 PM
I am trying to automate a simple process, but, I am new to script-fu and trying to get my bearings.
I am going to describe what I am trying to do, where I am failing, and perhaps find an example to what I am trying to do.
The Task
I have an image (myimage.xcf) which has a background layer (256 by 256, RGB, background transparancy)
as well as 200 "mask" layers
The background image is a texture (think carpet or steel image)
The mask layers have two colors - black and white
The Process
This script need to run against the currently selected image, non-interactively
For each of the mask layers (named mask1, mask2 etc)
The script will make a copy of the background layer called "current work"
Using the current mask, it will select by color (black) switch to the "current work" layer and apply the script-fu-add-bevel
The script will then go back to the current mask layer and select by color(white), switch to the "current work" layer and delete the selection
The script will then export the "current work" to a png file, delete the "current work" layer and repeat the process for the next mask layer.
The Problem
The thing is, while I know I can refer to layers by number, how do I find a layers ID by name ie
While I can use (gimp-image-get-active-drawable 1) to get the layer number for the currently selected layer, how do I get the layer number for the layer named "background"?
I can set a layer manually at position 0, but, I can't find instructions on how to switch layers based upon position or to switch layers based upon name.
I wish there was a "recorder" process that just created a script that repeated what the user was doing like a macro, but, I can not find such a thing and it is beyond my ability to write it.
Any guidance on how to associate a layer(items) number based upon it's name or it's position in the layer list, would be appreciated.
Thanks in advance
I am going to describe what I am trying to do, where I am failing, and perhaps find an example to what I am trying to do.
The Task
I have an image (myimage.xcf) which has a background layer (256 by 256, RGB, background transparancy)
as well as 200 "mask" layers
The background image is a texture (think carpet or steel image)
The mask layers have two colors - black and white
The Process
This script need to run against the currently selected image, non-interactively
For each of the mask layers (named mask1, mask2 etc)
The script will make a copy of the background layer called "current work"
Using the current mask, it will select by color (black) switch to the "current work" layer and apply the script-fu-add-bevel
The script will then go back to the current mask layer and select by color(white), switch to the "current work" layer and delete the selection
The script will then export the "current work" to a png file, delete the "current work" layer and repeat the process for the next mask layer.
The Problem
The thing is, while I know I can refer to layers by number, how do I find a layers ID by name ie
While I can use (gimp-image-get-active-drawable 1) to get the layer number for the currently selected layer, how do I get the layer number for the layer named "background"?
I can set a layer manually at position 0, but, I can't find instructions on how to switch layers based upon position or to switch layers based upon name.
I wish there was a "recorder" process that just created a script that repeated what the user was doing like a macro, but, I can not find such a thing and it is beyond my ability to write it.
Any guidance on how to associate a layer(items) number based upon it's name or it's position in the layer list, would be appreciated.
Thanks in advance