0

我尝试使用 gimp 2.8 制作这个脚本。

我在过程浏览器中没有看到 script-fu-register)。

我尝试使用 RUN-INTERACTIVE 和 RUN-NONINTERACTIVE 运行...这个脚本:

 (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()

我用它来运行它:

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

它在用户主文件夹上的图像。

我得到的错误:

~$ 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
4

1 回答 1

1

错误显示“未绑定变量:myimage”。这告诉您您指的是一个名为“myimage”的变量/函数,但您从未定义过该变量,因此它不知道“myimage”代表什么。

你知道“myimage”应该代表什么吗?你是从别人的剧本里抄来的吗?

函数 gimp-file-load 返回一个包含您打开的图像的列表。您需要使用“car”函数从该列表中提取第一个条目,以便将其存储在您的“img”变量中。因此,而不是 (img (myimage (gimp-file-load RUN-INTERACTIVE filename filename))) 它应该说 (img (car (gimp-file-load RUN-INTERACTIVE filename filename)))

另外,我认为您可能想改用 RUN-NONINTERACTIVE 。

同样,我认为您需要将 (my image ...) 的其他实例更改为 (car ...) 。

于 2013-08-06T17:10:54.697 回答