Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

How to merge down layer copy

Thu Apr 23, 2020 11:49 pm

Hi everyone. I'm trying to create a heart shape and I been successfully up to almost the last part of the script. Now I need to merge down the duplicated copy but I'm getting a fail error " Failed: There is no visible layer to merge down to." What I need to change in the code? Thank you in advanced!

Code:
(define (script-fu-create-heart)
    (let* (
        (img  (car (gimp-image-new 500 500 RGB)))
        (layer (car (gimp-layer-new img 500 500 RGB-IMAGE "Background" 100 LAYER-MODE-NORMAL)))
      (theheart (car (gimp-layer-new img 500 500 RGB "Heart" 100 LAYER-MODE-NORMAL)))
      (layer-mask 0)
      
      )


      ;Create the Background
        (gimp-image-undo-disable img)              ; Disable undo during the image creation
        (gimp-image-insert-layer img layer 0 0)
      (gimp-context-set-foreground '(000 000 00))
      (gimp-drawable-fill layer FILL-FOREGROUND)
      
      ;Create the heart layer
      (gimp-image-add-layer img theheart -1)
      (gimp-layer-add-alpha theheart)
      (gimp-drawable-fill theheart FILL-TRANSPARENT)
      
      ;Create the the first half of the heart
      (gimp-image-select-ellipse img  2 60 105 385 285)
      (gimp-image-select-rectangle img  1  30  50  440  200)
      (gimp-image-select-ellipse img  0 58 143 385  215)
      (gimp-context-set-foreground '(221 0 0))
      (gimp-drawable-edit-fill theheart FILL-FOREGROUND)
      (gimp-selection-none img)
      (gimp-item-transform-rotate theheart  45.00  TRUE   250.50  268.00)
      (gimp-layer-resize-to-image-size theheart)
      (gimp-image-select-rectangle img  2  0  0  250  500)
      
      (set! layer-mask (car (gimp-layer-create-mask theheart ADD-MASK-SELECTION)))
      (gimp-layer-add-mask theheart layer-mask)
      (gimp-layer-remove-mask theheart 0)
      (gimp-selection-none img)
      
      ;Create the second half of the heart
      (gimp-image-duplicate img)
      (gimp-image-flip img ORIENTATION-HORIZONTAL)
      
      (gimp-image-merge-down img layer 1)
      
      
            
      (gimp-image-undo-enable img)
      
      
      
      
      (gimp-display-new img)
      

Re: How to merge down layer copy

Fri Apr 24, 2020 1:50 am

Hello, Pocholo, :)

You have created duplicate image without assignement... useless.

You have to :
- create a copy of theheart --> halfHeart
- flip the layer halfHeart
- merge down halfHeart
- verify everything is useful in your script

Have fun. :)
@+++

Re: How to merge down layer copy

Fri Apr 24, 2020 2:10 am

After creating a layer, you have to add/insert it in the image (this applies to each of your two layers). This sets its position, and Gimp will know what to do when you merge.
Post a reply