Script-fu
I'm writing a script that works on an open image. So I'm starting with a layer that I don't have an id for. I want to change the name of that layer so I have a set variable that I can work with through out the script. Also, if I ever merge visible, I would like to be able to name that new layer.
I sorry if this is so simple. I truly have looked around forums and read other peoples scripts but I can't work it out. Ideally, I would like to be able to combine "(gimp-image-get-active-layer image)" and "(gimp-item-set-name item name)" in some fashion to change the layer name. That way I know I can change the layer name at any time.
I know this is probably not the proper way. I'd guess I could get a little greedy here and ask for both solutions. i.e. working out how to use get-active/set-name and maybe if someone is willing to explain the proper way of changing the layer name of a newly opened image.
I do appreciate any help.
Thanks.
I've included the code (children's book : )) so you can better understand my inquiry.
(define (script-fu-pd image drawable)
(gimp-context-push)
(gimp-image-undo-group-start image)
(gimp-image-merge-visible-layers image CLIP-TO-IMAGE)
(set! drawable (car (gimp-image-get-active-drawable image)))
(gimp-image-convert-grayscale image)
(gimp-context-set-foreground '(0 0 0))
(gimp-context-set-background '(255 255 255))
;this is the point I decided I needed to have the opened image layer renamed
so that I can work with it using the presets in the Procedure Browser.
(gimp-image-undo-group-end image)
(gimp-context-pop)
(gimp-displays-flush)
)
(script-fu-register "script-fu-pd"
"<Image>/Filters/PD grayscale Threshold"
"Inprogress"
"PD"
"PD"
"July 2012"
"RGB*"
SF-IMAGE "image" 0
SF-DRAWABLE "drawable" 0
)