在 Windows 环境中,我想调用 GIMP 以执行 python-fu 脚本(通过 BAT 文件),但我正在使用的命令行调用不会产生预期的结果。
例如,考虑以下名为 的 python-fu 脚本makeafile_and_quit.py
,它位于我的 GIMPplug-ins
文件夹中。其目的是加载现有图像并以不同的名称保存:
#!/usr/bin/env python
# Sample call from GIMP's python-fu console:
# pdb.python_fu_makeafile_and_quit_script()
from gimpfu import *
def makeafile_and_quit( ) :
FILEPATH = 'C:\\path\\to\\file.JPG'
IMAGE = pdb.gimp_file_load( FILEPATH, FILEPATH )
pdb.gimp_file_save( IMAGE, pdb.gimp_image_get_active_drawable( IMAGE ), FILEPATH + '_2.jpg', FILEPATH + '_2.jpg' )
pdb.gimp_quit(0)
return
# PLUGIN REGISTRATION
# This is the plugin registration function
register(
'makeafile_and_quit_script',
'v0.0',
'A new concept',
'Author',
'Author',
'Just now',
'<Toolbox>/MyScripts/This will make a file and _QUIT',
'',
[],
[],
makeafile_and_quit
)
main()
如果从 GIMP 的“GUI 实例”调用脚本,脚本将完美执行,通过菜单调用脚本。它会在与源文件相同的文件夹中生成一个以“_2.jpg”结尾的新文件。
使用以下命令从命令提示符调用时行为不同:
"C:\Program Files\GIMP 2\bin\gimp-2.8.exe" --batch '("makeafile_and_quit.py")' -b "(gimp-quit 0)"
创建一个 GIMP 实例,然后关闭,但即使batch command executed successfully
看到消息,也不会创建文件。
如何从命令行重复与“GUI 实例”完全相同的行为?