Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
script-fu help
#1
Hi, I have a script-fu script I wrote back in 2003, which I use to save the current image in the ../edited folder, and mark the image as "saved". I have been using this script in every version of Gimp since 2003 without changes, but when I tried to use it in Gimp 3.0 I got the error:

Execution error for 'DoIt':
Error: eval: unbound variable: gimp-image-get-filename

Does anybody know if the function gimp-image-get-filename has changed in Gimp 3.0, or if I'm missing something in my Gimp installation?

Thanks,
Eric
Reply
#2
The procedure browser lists those:

gimp-image-get-file
gimp-image-get-name
gimp-image-get-xcf-file

I don't know which one you're looking for, but the procedure browser give some description (you should use it, it's in the help menu)
Reply
#3
(03-08-2026, 11:52 PM)Scallact Wrote: The procedure browser lists those:

gimp-image-get-file
gimp-image-get-name
gimp-image-get-xcf-file

I don't know which one you're looking for, but the procedure browser give some description (you should use it, it's in the help menu)

Thanks for the response. gimp-image-get-file may be a start, but that seems to return the file object. What I need is the full file name, including the path, in order to find the image's _parent_ directory. I need to create a file name that is in a _sibling_ directory of the image.

So how do I get the whole file name? According to the description, the gimp-image-get-name only gets the image's base name (the name inside the directory).
Reply
#4
In python, it's possible with the method .get_path() appended to a Gio.File object. 

Is there a complete doc somewhere, where the GFile format is described?

I have no experience with script-fu, and sadly can't help you further. Hope someone can give better advises.
Reply
#5
(03-08-2026, 07:43 PM)egrivel Wrote: Hi, I have a script-fu script I wrote back in 2003, which I use to save the current image in the ../edited folder, and mark the image as "saved".

Things change and I have just about given up  with both script-fu and python 3

I use possibly a similar script-fu, but using the layer name which is often the same as the file name.

   

For what it is worth, the attached script (cut-down a bit from the one I currently use) takes the open image and dumps it to the home folder as a jpeg.  There might be enough to get you started converting your old script.


Attached Files
.scm   quick-save-jpg.scm (Size: 1.25 KB / Downloads: 11)
Reply
#6
Below is a script to print the results of calling the three procedures Scallact listed in post #2.
It shows that in scheme gimp turns the returned GFile into a string.

Example of the script's printouts:
gimp-image-get-file: Is a string: /tmp/test-filenames.xcf
gimp-image-get-name: Is a string: test-filenames.xcf
gimp-image-get-xcf-file: Is a string: /tmp/test-filenames.xcf

Code:
#!/usr/bin/env gimp-script-fu-interpreter-3.0

(define (print-info procedure-name value)
 (display procedure-name)
 (display ": ")

 (cond
   ((not (string? value)) (display "Is not a string: "))
   ((string=? value "")   (display "Is an empty string."))
   (else                  (display "Is a string: "))
 )

 (display value)
 (newline)
)

(define (script-fu-test-filename-v3 image drawables)
 (script-fu-use-v3)

 (let ((file (gimp-image-get-file image))
       (name (gimp-image-get-name image))
       (xcf-file (gimp-image-get-xcf-file image)))

   (print-info "gimp-image-get-file" file)
   (print-info "gimp-image-get-name" name)
   (print-info "gimp-image-get-xcf-file" xcf-file)
 )
)

(script-fu-register-filter "script-fu-test-filename-v3"
   "Test Filename v3"
   "Print out some filename tests."
   "teapot"
   "teapot"
   "2025"
   "*"
   SF-ONE-OR-MORE-DRAWABLE
)

(script-fu-menu-register "script-fu-test-filename-v3" "<Image>/Image")
Reply


Forum Jump: