[Gimp-user] script-fu question



Hi,
I recently wrote a script for gimp with script-fu.  I have two questions.  I would kindly appreciate any 
suggestions.

1. I obtain the following warning:
           (/usr/lib64/gimp/2.0/plug-ins/script-fu/script-fu) is installing procedure "script-fu-apply-grid2" 
with a full menu path "<Image>/Script-Fu/Muntins" as menu label, 
           this deprecated and will be an error in GIMP 3.0    I see other posts regarding this warming but 
no guidance on what the current practice is to define a menu label.  Can you please advise on how the menu 
label should be    described?
2. I get the following message when I close gimp after running the script:
            EEEEeEeek! 1 GeglBuffers leaked
     I assume I have an image still active based upon google searching.  I have created two images (image and 
image1).  When I use gimp-image-delete, one is deleted and I get an error indicating that it does not exist.  
Before I attempt to delete the images. I use gimp-image-list which indicates that I have two images and there 
id's.  After I delete the delectable image, I run gimp-image-list again.  It reports 1 image but no id.  No 
wonder I can not delete is since there is no id.  The script is shown below.  It reads in a transparent svg 
file, puts iton a whte background and then selects nine region in a matrix pattern with each selection 
written to a file.  Would anyone have advise on this issue?
Thank you in advance for your help.
Al
(define (script-fu-muntin infile ext)
  (define (filename-basename orig-name)
    (car (strbreakup orig-name ".")))
  (define base (filename-basename infile))
  (set! base (string-append base "_"))
  (define num  #("1" "2" "3" "4" "5" "6" "7" "8" "9"))
  (define idx)
  (define outfile)
  (define h0 1080)
  (define w0 1920)
  (define h1 3314)
  (define w1 5834)
  
; determine svg aspect ratio
  (define image0 (let ((image0 (car (gimp-file-load RUN-NONINTERACTIVE infile "")))) image0))
  (define w (car (gimp-image-width image0)))
  (define h (car (gimp-image-height image0)))
  (gimp-image-delete image0)
  (define w1a (round (* (/ w h) h1)))
  (define off_set (round (/ (- w1a w1) 2)))

; read in the svb to the desired size and define canvas1 for pasting the cutout selection to
;  (let* ((image (car (file-svg-load  RUN-NONINTERACTIVE infile infile 90. w1a h1 0)));
;     (layer (car (gimp-layer-new image w1 h1 RGB-IMAGE "canvas" 100 LAYER-MODE-NORMAL)))
;     (image1 (car (gimp-image-new w0 h0 RGB)))
;     (layer1 (car (gimp-layer-new image1 w0 h0 RGB-IMAGE "canvas1" 100 LAYER-MODE-NORMAL)))
;     )
;    )
  (define image (let* ((image (car (file-svg-load  RUN-NONINTERACTIVE infile infile 90. w1a h1 0)))) image))
  (define layer (let* ((layer (car (gimp-layer-new image w1 h1 RGB-IMAGE "canvas" 100 LAYER-MODE-NORMAL)))) 
layer))
  (define image1 (let* ((image1 (car (gimp-image-new w0 h0 RGB)))) image1))
  (define layer1 (let* ((layer1 (car (gimp-layer-new image1 w0 h0 RGB-IMAGE "canvas1" 100 
LAYER-MODE-NORMAL)))) layer1))
  (gimp-image-insert-layer image layer 0 1)
  (gimp-drawable-fill layer WHITE-FILL)
  (gimp-layer-set-offsets layer off_set 0)
;  (define layers2 (gimp-image-merge-visible-layers image EXPAND-AS-NECESSARY))   
  (gimp-image-merge-visible-layers image EXPAND-AS-NECESSARY)   
  (gimp-image-resize-to-layers image)
  (gimp-displays-flush)
;  (define image2 (gimp-display-new image))    
  (gimp-display-new image)    
  (define drawable (car (gimp-image-get-active-layer image)))
;    (gimp-file-save RUN-NONINTERACTIVE image drawable "batman_logo0.png" "batman_logo_0.png")

  (gimp-image-insert-layer image1 layer1 0 0)
  (gimp-displays-flush)
  (define drawable1 (car (gimp-image-get-active-layer image1)))    

; generate 9 images in a 3x3 matrix pattern and write out selection  
  (define sel-float)
  (define idx)
  (define outfile)
  (define x 0)
  (define y 0)
  (define i 0)
  (while (< x (* 3 w0))
     (define w x)
     (set! y 0)
     (while (< y (* 3 h0))
        (define h y)
        (gimp-image-select-rectangle image CHANNEL-OP-REPLACE w h w0 h0)
;        (define drawable2 (gimp-edit-copy drawable))
        (gimp-edit-copy drawable)    
        (set! sel-float (car (gimp-edit-paste drawable1 FALSE)))
        (gimp-floating-sel-anchor sel-float)
        (gimp-displays-flush)
        (set! idx (vector-ref num i))
        (set! outfile (string-append base idx "." ext))
        (gimp-file-save RUN-NONINTERACTIVE image1 drawable1 outfile "")
        (set! y (+ y (+ h0 37)))
        (set! i (+ i 1))
        )
     (set! x (+ x (+ w0 37)))
     )

;determine image count  
  (define n (car (gimp-image-list)))
  (gimp-message (number->string n))
  (define m (car (cdr (gimp-image-list))))
  (define j 0)
  (while (< j n)
     (define value (vector-ref m j))
     (gimp-message (number->string value))
     (set! j (+ j 1))
     )
  
  (gimp-selection-none image)
  (gimp-image-delete image1)

; determine image count
  (define n (car (gimp-image-list)))
  (gimp-message (number->string n))
  (define m (car (cdr (gimp-image-list))))
  (define j 0)
  (while (< j n)
     (define value (vector-ref m j))
     (gimp-message (number->string value))
     (set! j (+ j 1))
     )  
)

(script-fu-register
   "script-fu-muntin"
;   "<Image>/File/Create/Muntin"
   "<Image>/Script-Fu/Muntin"
   "Crop image to form muntin"
   "me"
   "me"
   "October 2021"
   ""
   SF-STRING "infile" "/home/me/Desktop/svg/batman_logo.svg"
   SF-STRING "extension" "png"
)




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]