我正在尝试使用 pythonfu 编写一个 gimp 脚本。但是,当我尝试在本地运行脚本时,出现错误
`--> ./vvv.py
Traceback (most recent call last):
File "./vvv.py", line 5, in <module>
from gimpfu import *
ImportError: No module named gimpfu
我认为该脚本可能只能通过 gimp 加载。但是,该脚本不会出现在 gimp 菜单中。在那种情况下,我如何获得错误输出?
最佳答案
根据您的操作系统,您必须寻找 GIMP 插件的目录,例如:
GIMP 2\lib\gimp\2.0\plug-ins
然后将您的脚本复制到那里。当然你必须添加这样的注册内容:
register(
"python-fu-draw", #<- this is plugin name
N_("brief"), #<- description
"Long", #<- description
"name surname", #<- author
"@Copyright 2013", #<- copyright info
"2013/10/29", #<- creation date
N_("_Draw..."), #<- label shown in gimp's menu
"", #<- kind of image requested from your script (INDEX,RGB,...and so on)
[ #<- input parameters array
(PF_FILE, "ifile", N_("Color input file"), 'default.txt'),
],
[], #<- output parameters array (usually empty)
draw, #<- main method to call
menu="<Image>/Filters/", #<- Where add your plugin
domain=("gimp20-python", gimp.locale_directory)
)
main() #<- don't forget this
一旦你将脚本复制到正确的目录中并使用正确的注册内容,你就可以运行 GIMP 并运行你的脚本,在你在注册内容中选择的下拉菜单中选择它。 您不必从 python 控制台运行它。所以那些是行不通的:
python myscript.py
./myscript.py
>>> myscript
要以交互方式调试脚本,请从 gimp 打开 python-fu 控制台:
Filters->Python-fu->Console
看看this网站。主要是幻灯片很有用。
如果您想以批处理模式运行脚本,请查看 this
关于python 无法导入 gimpfu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18986723/