我尝试使用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
答案 0 :(得分:1)
错误显示“unbound variable: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。
同样,我认为你需要改变彼此的实例 (我的形象......) 成为 (车......) 代替。