Hello,
I would like to copy a selection in a new layer by a script-fu. But I'm a beginner in script-fu and I don't know how do it :
This is the plugin with no any copy :
;;------------------------------------
(define (script-fu-image-partietransp inImage inCalque inTransparence inColorFond inFlouOmbre inColorOmbre inDecalageOmbreX inDecalageOmbreY)
(let* (
;;PARTIE Floue
(calqueFloue (car (gimp-layer-new
inImage
(car (gimp-image-width inImage))
(car (gimp-image-height inImage))
RGB-IMAGE "floue" inTransparence NORMAL-MODE)))
;;PARTIE Ombre
(calqueOmbre (car (gimp-layer-new
inImage
(car (gimp-image-width inImage))
(car (gimp-image-height inImage))
RGBA-IMAGE "ombre" 100 NORMAL-MODE)))
;;SELECTION
(calqueVisible)
)
;;PARTIE FLOUE
(gimp-context-set-background inColorFond)
(gimp-drawable-fill calqueFloue BG-IMAGE-FILL)
(gimp-image-add-layer inImage calqueFloue 0)
;;PARTIE Ombre
(gimp-image-add-layer inImage calqueOmbre 0)
;;Remplir Ombre
(gimp-context-set-foreground inColorOmbre)
(gimp-edit-bucket-fill calqueOmbre 0 0 100 0 0 0 0)
(gimp-selection-all inImage)
(plug-in-gauss 1 inImage calqueOmbre inFlouOmbre inFlouOmbre 0)
(gimp-drawable-offset calqueOmbre TRUE 1 inDecalageOmbreX inDecalageOmbreY)
(gimp-displays-flush inImage)
)
)
(script-fu-register
"script-fu-image-partietransp" ;func name
"image transparence" ;menu label
"Ce script s'occupe de rendre floue la quasi totalité de l'image sauf
une region selectionnee au prealable." ;description
"Tobias BORA" ;author
"rien" ;copyright notice
"Mars 27, 2011" ;date created
"RGB" ;image type that the script works on
SF-IMAGE "Image" 0
SF-DRAWABLE "Calque" 0
SF-ADJUSTMENT "Transparence" '(75 0 100 1 10 1 0)
SF-COLOR "Couleur arrière plan :" '(255 255 255) ;color variable
SF-ADJUSTMENT "Flou ombre" '(30 0 100 1 10 1 0)
SF-COLOR "Couleur Ombre" '(0 0 0) ;color variable
SF-ADJUSTMENT "Décalage ombre X" '(2 -20 20 1 5 0 0)
SF-ADJUSTMENT "Décalage ombre Y" '(2 -20 20 1 5 0 0))
(script-fu-menu-register "script-fu-image-partietransp" "/Xtns/Script-Fu/Image")
;;----------------------
I tried to do this :
;;------------------------------
(define (script-fu-image-partietransp inImage inCalque inTransparence inColorFond inFlouOmbre inColorOmbre inDecalageOmbreX inDecalageOmbreY)
;;(gimp-image-undo-group-start inImage)
(let* (
;;PARTIE Floue
(calqueFloue (car (gimp-layer-new
inImage
(car (gimp-image-width inImage))
(car (gimp-image-height inImage))
RGB-IMAGE "floue" inTransparence NORMAL-MODE)))
;;PARTIE Ombre
(calqueOmbre (car (gimp-layer-new
inImage
(car (gimp-image-width inImage))
(car (gimp-image-height inImage))
RGBA-IMAGE "ombre" 100 NORMAL-MODE)))
;;SELECTION
(calqueVisible)
; (selection (car (gimp-image-get-selection inImage)))
; (calqueCopie (car (gimp-edit-copy inCalque)))
; (calqueFlottant (car (gimp-edit-paste calqueCopie FALSE)))
; (calqueVisible (car (gimp-floating-sel-anchor calqueFlottant)))
;; (gimp-edit-copy selection)
;; (selectionFlottante (car (gimp-edit-paste selection FALSE)))
;; (gimp-floating-sel-anchor floating-sel)
)
;;PARTIE FLOUE
(gimp-context-set-background inColorFond)
(gimp-drawable-fill calqueFloue BG-IMAGE-FILL)
(gimp-image-add-layer inImage calqueFloue 0)
;;PARTIE Ombre
(gimp-image-add-layer inImage calqueOmbre 0)
;;Remplir Ombre
(gimp-context-set-foreground inColorOmbre)
(gimp-edit-bucket-fill calqueOmbre 0 0 100 0 0 0 0)
(gimp-selection-all inImage)
(plug-in-gauss 1 inImage calqueOmbre inFlouOmbre inFlouOmbre 0)
(gimp-drawable-offset calqueOmbre TRUE 1 inDecalageOmbreX inDecalageOmbreY)
;;Partie Visible
(gimp-image-undo-group-start inImage)
(gimp-edit-copy inCalque)
(set! calqueVisible (car (gimp-edit-paste)))
(gimp-floating-sel-anchor(car (gimp-edit-paste calqueOmbre 0)))
; (gimp-image-add-layer inImage calqueVisible 0)
(gimp-image-delete calqueVisible)
(gimp-displays-flush inImage)
(gimp-image-undo-group-end image)
)
)
(script-fu-register
"script-fu-image-partietransp" ;func name
"image transparence" ;menu label
"Ce script s'occupe de rendre floue la quasi totalité de l'image sauf
une region selectionnee au prealable." ;description
"Tobias BORA" ;author
"rien" ;copyright notice
"Mars 27, 2011" ;date created
"RGB" ;image type that the script works on
SF-IMAGE "Image" 0
SF-DRAWABLE "Calque" 0
SF-ADJUSTMENT "Transparence" '(75 0 100 1 10 1 0)
SF-COLOR "Couleur arrière plan :" '(255 255 255) ;color variable
SF-ADJUSTMENT "Flou ombre" '(30 0 100 1 10 1 0)
SF-COLOR "Couleur Ombre" '(0 0 0) ;color variable
SF-ADJUSTMENT "Décalage ombre X" '(2 -20 20 1 5 0 0)
SF-ADJUSTMENT "Décalage ombre Y" '(2 -20 20 1 5 0 0))
(script-fu-menu-register "script-fu-image-partietransp" "/Xtns/Script-Fu/Image")
;;-------------------
But it doesn't work...
How could I copy the selection and paste it in a new layer ?
Thanks.
Tobias Bora
Important : Excuse me if I make any speeling mistakes, I'm French and my English isn't perfect...
Did you know
this is already possible in Gimp?
Make your selection
go to Edit/Copy
create a new layer -select the new layer
Edit/Paste
OR
Edit/paste as new layer
select/none
You can also paste your selection in place by using
Edit/copy
Edit/paste into - select new layer
Didn't know if you knew that or not.
Yes, I know that, but I would
Yes, I know that, but I would like to do it with a script fu... And I don't know how.
gimp-floating-sel-to-layer
After you have a floating selection, use 'gimp-floating-sel-to-layer' instead of 'gimp-floating-sel-anchor'. Note that the new layer will be placed at the very top of the layerstack -- you may need to lower it ('gimp-image-lower-layer') if that's not what you want.