1

我一直在Gimp:python 脚本没有显示在菜单中,它对我没有帮助。这是我一步一步尝试的:

1.我在 Mac OS X 10.9.5 上从命令行运行 Gimp 2.8.16,gimp因为我的.bashrc文件包括

alias gimp='/Applications/GIMP.app/Contents/MacOS/GIMP --verbose --console-messages '

我查看终端输出,我看到很多消息,但没有弹出任何问题(你想要这里的转储吗?)。我一开始就看到了,Enabling internal Python...所以应该很好。

2. Filters > Python-Fu > Console 调出控制台,有

GIMP 2.8.16 Python Console
Python 2.7.8 (default, Dec  5 2015, 09:38:54) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
>>> 

——所以,python 似乎又在工作了。

3.因为这里的这个技巧,我尝试运行一个 Python 脚本。我打开一张图片并运行过滤器 > 渲染 > 云 > 雾。像魅力一样工作——在控制台中,当窗口启动时,我确实收到了一些类型转换警告:

** (foggify.py:30312): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'
** (foggify.py:30312): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'
** (foggify.py:30312): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'

我搜索了我的计算机,foggify.py 实际上在其中,/Applications/GIMP.app/Contents/Resources/lib/gimp/2.0/plug-ins/foggify.py因此这证明 Python 正在工作,但不能证明它正在加载脚本。我有点困惑,因为foggify.py只有 77 行,而不是 30312。

4. GIMP > Preferences > Folders > Scripts 显示 GIMP 应该为脚本加载以下目录:

/Users/julio/Library/Application Support/GIMP/2.8/scripts
/Applications/GIMP.app/Contents/Resources/share/gimp/2.0/scripts

我没有使用/Applications/GIMP.app/Contents/Resources/share/gimp/2.0/scripts,但它有很多*.scm文件(所以,可能都在 Scheme 中)。我自己从来没有在这里添加任何东西。

5.我只有一个脚本:ls -l "/Users/julio/Library/Application Support/Gimp/2.8/scripts"yield

total 8
-rwxr-xr-x  1 julio  staff  654 25 Jun 16:25 minimal.py

(没有其他的)

6.这是我的minimal.py

#!/usr/bin/env python

from gimpfu import *

def minimal():
    pass

register(
    "python_fu_minimal",                                    # plugin name
    "Minimal plug-in example",                              # blurb (short description)
    "Show the smallest possible Python plug-in example",    # help (long description)
    "Michael Schumacher",                                   # author
    "Michael Schumacher",                                   # copyright info
    "2007",                                                 # date
    "<Image>/Tools/Minimal",                                # menu position and label
    None,                                                   # image types accepted
    [],                                                     # input parameters
    [],                                                     # output (results)
    minimal                                                 # method to call
    )

main()

7.已经在上面指示的目录中运行gimp,我在“工具”菜单中看不到任何“最小”项。minimal.py scripts

我还尝试了下面的变体,它也不起作用:

#!/usr/bin/env python

from gimpfu import *

def minimal():
    pass

register(
    "python_fu_minimal",                                    # plugin name
    "Minimal plug-in example",                              # blurb (short description)
    "Show the smallest possible Python plug-in example",    # help (long description)
    "Michael Schumacher",                                   # author
    "Michael Schumacher",                                   # copyright info
    "2007",                                                 # date
    "Minimal",                                              # menu position and label
    None,                                                   # image types accepted
    [],                                                     # input parameters
    [],                                                     # output (results)
    minimal,                                                # method to call
    menu="<Image>/Tools"
    )

main()
4

1 回答 1

3

Python“脚本”在技术上是“插件”,因此应该位于“插件”子目录(/Users/julio/Library/Application Support/GIMP/2.8/plug-ins)中。

2.10 更新:Gimp 2.10 仍然支持 2.8 方式,将.py文件放在plug-ins目录中,但它也支持新样式,其中.py(实际上是主插件可执行文件)位于具有相同名称的子目录中plug-ins,以及其他它可能需要的文件,如果有的话。AFAIK 这将是未来 Gimp 版本中唯一接受的方式。

{Your Gimp profile}
└── plug-ins
    ├── some_2.08_plugin.py
    ├── another_2.08_plugin.py
    ├── some_plugin_for_2.10_and_beyond
    │   ├── some_plugin_for_2.10_and_beyond.py
    │   └── some_python_module.py
    └── another_plugin_for_2.10_and_beyond
        ├── another_plugin_for_2.10_and_beyond.py
        └── another_auxiliary_file.dat
于 2016-06-26T11:22:53.637 回答