Re: [Gimp-user] script-fu question

2021-10-19 Thread Kevin Cozens

On 2021-10-16 7:56 a.m., att80 att.net wrote:

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 "/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.


The script name and full menu path goes in to a script-fu-menu-register 
call. It has been that way since GIMP 2.4, IIRC. You can see examples of it 
in any of the scripts that are shipped with GIMP. It is also mentioned in 
the page at https://static.gimp.org/tutorials/Basic_Scheme/



2. I get the following message when I close gimp after running the script:
         eEeek! 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. [snip]
   (gimp-display-new image)


I didn't go through the script in detail as it was rather long. I did notice 
the above. You are creating a new display but did not save the image ID. You 
need to pay attention to functions that return a value and do something with 
the return values.


--
Cheers!

Kevin.

http://www.ve3syb.ca/   | "Nerds make the shiny things that
https://www.patreon.com/KevinCozens | distract the mouth-breathers, and
| that's why we're powerful"
Owner of Elecraft K2 #2172  |
#include  | --Chris Hardwick
___
gimp-user-list mailing list
List address:gimp-user-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-user-list
List archives:   https://mail.gnome.org/archives/gimp-user-list


[Gimp-user] script-fu question

2021-10-19 Thread att80 att.net
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 
"/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:
        eEeek! 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