How do I duplicate a layer at the script-fu (scheme) console?
Here is what I have done so far:
(gimp-image-list)
This tells me that the reference to my image is the number "1".
Next, I get a reference to the particular layer I want to duplicate:
(gimp-image-get-layer-by-name 1 "frame25")
The result of this tells me that the layer reference is the number "2".
I didn't see any functions for duplicating a layer, but I see that I can copy the layer and then insert it as a new layer.
(gimp-image-insert-layer 1 (car (gimp-layer-copy 2 TRUE)) 0 n)
But what is the value of n
? I want to insert the duplicate right above the existing layer, the same as duplicating the layer would do in the Layers dock. But I haven't been able to find any functions that return the "position" (as the script-fu procedure browser calls the 4th parameter to gimp-image-insert-layer) of the layer in the stack. None of the "gimp-layer-get-*" functions, for instance, seem to refer to position. I have tried to search for this on the web, but most people use "position" to refer to the offset of the layer, which is a completely unrelated thing.
(gimp-image-insert-layer 1 (gimp-layer-copy 2 TRUE) 0 n)