Hi, forks.

Here is a script. this copy a selection of the active layer and paste
it as new layer with its opacity
made by Ankh (thank you, Ankh in #gimp, irc.gimp.org)

but there is a problem.
size of the new layer is not its own size, is the same with the image.
so I tried to fix this script, but I failed. T_T

please, fix it.
and I want one more thing.

I'd like to add a function for pasting a content of clipboard as new layer.
I failed, either -_-

these are very simple function, and I can do using some menus and
keyboard shortcuts.
but sometime I need and repeating 2-3 steps makes me mad.
please help me.



code:

; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;
;
; This script copies the visible layers contained within the active
; image and pastes the results into a single layer at the top of the stack
; of the active image  It is an updated version of Karl Ward's merge-copy script
; which can be found here:
http://kward1979uk.deviantart.com/art/Merge-copy-28607825
;
; The Script can be found in the Image's Edit Menu under the name:
"Copy Visible & Paste"
;
; Special thanks to saulgoode at gimptalk.com for his suggestions on
improving the script.

; Define the Function
(define
 (copy-paste-new-layer
  inImage
  inDraw)

 ; Declare the Variables
 (let*
  ((theHeight (car (gimp-image-height inImage)))
   (theWidth (car (gimp-image-width inImage)))
   (theFloatingSelection) ; an undefined variable to be defined below.
   (theType (car (gimp-drawable-type-with-alpha inDraw))) ; returns
the drawables' type with an Alpha Channel
   (theSelection) ; undefined variable to contain the selected area in
the image.
   (theResult) ; undefined variable created below to hold the contents
of the Copied Layers
   (theOpacity (car (gimp-layer-get-opacity inDraw))) ; for layer opacity
  )

  ; Begin Undo Group
  (gimp-image-undo-group-start inImage)

  ; Copy the selection from the current layer
  (gimp-edit-copy inDraw)

  ; Get the selected area in the image and save it to a channel
  (set! theSelection (car (gimp-selection-save inImage)))

  ; Create a new layer called "Cpoied Layer" to hold the pasted selection
  (set! theResult (car (gimp-layer-new inImage theWidth theHeight
theType "Copied Layer" theOpacity NORMAL-MODE)))

  ; Fills theResult Layer (aka Copied Layer) with transparent fill
  (gimp-drawable-fill theResult TRANSPARENT-FILL)

  ; Adds theResult Layer to the active image
  (gimp-image-add-layer inImage theResult 0)

  ; Defines theFloatingSelection variable as containing the pasted
layer and keeping the selection active
  (set! theFloatingSelection (car (gimp-edit-paste theResult FALSE)))

  ; Anchor theFloatingSelection to theResult
  (gimp-floating-sel-anchor theFloatingSelection)

  ; Reload the original selection (theSelection)
  (gimp-selection-load theSelection)

  ; Delete the channel holding the original selection (theSelection)
  (gimp-image-remove-channel inImage theSelection)

  ; End Undo Group
  (gimp-image-undo-group-end inImage))

  ; Update display
  (gimp-displays-flush))

(script-fu-register  "copy-paste-new-layer"
               "<Image>/Edit/Copy/Copy & Paste as Layer"
               "Copies the selection to a new layer and pastes it in
into active image"
               "Art Wade"
               "Art Wade"
               "December 2007"
               ""
               SF-IMAGE      "SF-IMAGE" 0
               SF-DRAWABLE   "SF-DRAWABLE" 0

)



Greetings.
-- 
〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
Choi, JiHui
http://Mr-Dust.pe.kr
http://GIMP.kr
_______________________________________________
Gimp-user mailing list
Gimp-user@lists.XCF.Berkeley.EDU
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-user

Reply via email to