Gimp - Script-Fu: insert from cache to new layer, inserted in layer map

375 Views Asked by At

I want to insert the current image in the cache to my current gimp project. You can easily do this by ctrl+v, but then the new layer is floating. When you create a new layer out of it, it will be the first layer and I have to drag it to the right position in the layer map. When I use "insert as new layer", the layer will be correctly sorted in the layermap, but the insert wont be on the x/y position of the previously selected layer!

I found a script that does something very similar, but it uses gimp-edit-copy & gimp-edit-paste to insert the layer, which isnt what i want. How can I change this, so it will insert the image from cache instead?

(define (script-fu-selection-to-layer inImage inLayer)
(let*
  (
    (isgroup (car (gimp-item-is-group inLayer)))
    (parent (car (gimp-item-get-parent inLayer)))
    (layername (car (gimp-item-get-name inLayer)))
    (position (car (gimp-image-get-item-position inImage inLayer)))
    (newlayer 0)
  )
  (if (= isgroup 0)
    (begin
      (gimp-image-undo-group-start inImage)
      (gimp-edit-copy inLayer)
      (set! newlayer (car (gimp-edit-paste inLayer 1)))
      (gimp-floating-sel-to-layer newlayer)        
      (gimp-item-set-name newlayer (string-append "insert-" layername))
      (gimp-image-reorder-item inImage newlayer parent position)
      (gimp-selection-none inImage)
      (gimp-image-undo-group-end inImage)
    )
    (begin
       (gimp-message "not usable on layergroups")
    )
  )  
 )
)
1

There are 1 best solutions below

1
On BEST ANSWER

Just remove the (gimp-edit-copy inLayer) line and it should paste whatever is in the clipboard.