Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
script-fu - how to refer to the active image?
#10
(12-13-2022, 01:57 PM)programmer_ceds Wrote: The "*" should be in the line before the SF-IMAGE line.

So, like this, right?
Code:
           "*"                     ;image type that the script works on
           SF_IMAGE       ""         "whatever"   ;image variable
However the error remains the same

(12-13-2022, 01:57 PM)programmer_ceds Wrote: Specifying "" means that the script will be enabled whether or not there is an active image - which makes the SF-IMAGE parameter redundant - probably not what you want.
Actually I don't care at this point. I want a reference to the image, if there is an image. If I get a NULL or whatever undefined value, in case nothing is open, is unimportant to me right now.

(12-13-2022, 01:57 PM)programmer_ceds Wrote: A minor correction to what Ofnuts said - the script will only appear in the menu if GIMP hasn't detected a problem with it. In your case GIMP has detected a problem so no script in the menu.
Ok.
I mean, not ok: I want to get rid of this problem. But I understand, what you are saying.

(12-13-2022, 01:57 PM)programmer_ceds Wrote: It might be worth you looking at the standard Script-Fu scripts for V2.10 - the latest versions are at:

https://gitlab.gnome.org/GNOME/gimp/-/tr...fu/scripts
I don't understand them. E.g there is https://gitlab.gnome.org/GNOME/gimp/-/bl...-photo.scm
which might be similar to what I want, judging from the inImage in
Code:
(define (script-fu-old-photo inImage inLayer inDefocus inBorderSize inSepia inMottle inCopy)
But I see nothing there, which says, that the variable
Code:
inImage
is of type SF_IMAGE. How does gimp know, that it is expected to put a reference to the current image into that variable?

(12-13-2022, 01:57 PM)programmer_ceds Wrote: However, with a Script-Fu script any changes that you make to the script will not take effect until you either stop and restart GIMP or use "Filters/Script-Fu/Refresh Scripts" (note that this second option doesn't currently work with GIMP V2.99 - it simply removes all Script-Fu scripts from the menus!)

I'll do the restart thing to be on the secure side.
If I regress the script to 

Code:
           "*"                     ;image type that the script works on
;            SF_IMAGE       ""         "whatever"   ;image variable
           SF-STRING      "Text"          "Text Box"   ;a string variable
           SF-FONT        "Font"          "Charter"    ;a font variable
           SF-ADJUSTMENT  "Font size"     '(50 1 1000 1 10 0 1)
                                                       ;a spin-button
           SF-COLOR       "Color"         '(0 0 0)     ;color variable
           SF-ADJUSTMENT  "Buffer amount" '(35 0 100 1 10 1 0)
                                                       ;a slider
 )
 (script-fu-menu-register "script-fu-text-box" "<Image>/File/Create/Text")
 (define (script-fu-text-box inText inFont inFontSize inTextColor inBufferAmount)

it gets through quite nicely.  But I want to write a script, that operates on an existing image.
Reply


Messages In This Thread
RE: script-fu - how to refer to the active image? - by flauapaua - 12-14-2022, 05:39 PM

Forum Jump: