Question

I try to make working this script with gimp 2.8 .

I don't see script-fu-register in Procedure Browser).

I try running with RUN-INTERACTIVE and RUN-NONINTERACTIVE... this script:

 (define (script-fu-cut-height filename outputfilename myheight)
 (let* (
  (img (myimage (gimp-file-load RUN-INTERACTIVE filename filename)))
  (imagewidth (myimage (gimp-image-width img)))
  (imageheight (myimage (gimp-image-height img)))
  (width (- imagewidth (+ right left)))
  (height (- myheight (+ top bottom)))
  )
  (gimp-image-crop img width height left top)
  (gimp-png-save RUN-INTERACTIVE
    img
    (myimage (gimp-image-active-drawable img))
    outputfilename
    outputfilename)
 (gimp-image-delete img)
 ))

 (script-fu-register "script-fu-cut-height"
 "www.free-tutorials.org : script-fu"
 "Cut an image by height and let width default"
 "test"
 "www.free-tutorials.org"
 "Jul 2013"
 "RGB* GRAY*"
 SF-STRING "Filename" ""
 SF-STRING "OutputFilename" ""
 SF-VALUE "TopEdge" "0"
 SF-VALUE "RightEdge" "0"
 SF-VALUE "BottomEdge" "0"
 SF-VALUE "LeftEdge" "0"
 )
 script-fu-cut-height()

I use this to run it :

$ gimp -i -c -b "(script-fu-cut-height \"test-script-fu.png\" \"out-script-fu-output.png\" 85)" -b  "(gimp-quit 0)"

The image it's on user home folder .

The error I got :

~$ gimp -i -c -b "(script-fu-cut-height \"test-script-fu.png\" \"out-script-fu-       output.png\" 85)" -b  "(gimp-quit 0)"
Fontconfig warning: "/etc/fonts/conf.d/65-droid-sans-fonts.conf", line 103: Having     multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/65-droid-sans-fonts.conf", line 138: Having     multiple values in <test> isn't supported and may not work as expected
batch command experienced an execution error:
Error: (<unknown> : 136051114) eval: unbound variable: myimage 

Fontconfig warning: "/etc/fonts/conf.d/65-droid-sans-fonts.conf", line 103: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/conf.d/65-droid-sans-fonts.conf", line 138: Having multiple         values in <test> isn't supported and may not work as expected
Was it helpful?

Solution

The error says "unbound variable: myimage". This is telling you that you are referring to a variable/function called "myimage," but you never defined that variable, so it doesn't know what "myimage" represents.

Do you know what "myimage" is supposed to represent? Did you copy that from another person's script?

The function gimp-file-load returns a list containing the image that you opened. You need to use the "car" function to extract the first entry from that list, so that it can be stored in your "img" variable. So instead of (img (myimage (gimp-file-load RUN-INTERACTIVE filename filename))) it should say (img (car (gimp-file-load RUN-INTERACTIVE filename filename)))

Also, I think you might want to use RUN-NONINTERACTIVE instead.

Similarly, I think you will need to change each other instance of (my image ...) to be (car ...) instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top