I'd like to write simple script that: 1) make image smaller by 25% (width 50%, height 50%), 2) adds watermark from another image (finally I'd like to set opacity for that to 20%).
My problem is that I'm not fully aware what I do with layers I create. Script works (but it was pain to make it work!) for bunch of files, I change parameters, but it seems I cannot get it to work as I want to). I see no watermark image - except when I do gimp-file-save
for drawable2
(there's only watermark then).
May anyone help me with that? - and explain to me what I do wrong here?
(define (add-watermark2 pattern waterm)
(let* ((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let* ((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-active-drawable image)))
(cur-width (car (gimp-image-width image)))
(cur-height (car (gimp-image-height image)))
(width (* 0.50 cur-width))
(height (* 0.50 cur-height))
(gimp-image-scale image width height) ; scale the image
(drawable2 (car (gimp-file-load-layer RUN-NONINTERACTIVE image waterm)))
(gimp-image-insert-layer image drawable2 0 -1)
(gimp-layer-set-offsets drawable2 100 100 )
(gimp-layer-set-mode drawable2 0)
(gimp-image-merge-visible-layers image 2)
)
(gimp-file-save RUN-NONINTERACTIVE image drawable (string-append "w" filename) "")
)
(set! filelist (cdr filelist))
)))