如何解决Gimp 无法从 OSX 中的 shell 脚本正常启动
我使用的是 MacOS Mojave(10.14.16 版,包含所有更新的最新版本)并且我正在运行 Gimp 2.10。我制作了一个 Python 插件,它可以在命令行终端中很好地工作,但是我不能在 shell 脚本中使用它。该插件打开一个 XCF 模板,添加一个外部 JPG 作为新层,使用 x 和 y 偏移定位外部 JPG,展平,然后导出一个新的 JPG,在模板中显示外部 JPG。
背景信息:
在 OSX 中,仅在终端输入“gimp”并不会启动 Gimp,因此我使用此处描述的步骤在主目录 (/users/TimB) 的 .bash_profile 中创建了一个别名:https://mattmazur.com/2012/01/27/how-to-add-terminal-aliases-in-mac-os-x-lion/。别名如下:
alias gimp=”/Applications/GIMP-2.10.app/Contents/MacOS/gimp”
我的别名在命令行终端上运行良好,但在 shell 脚本中不起作用。
在我的 shell 脚本中,只是尝试在一行上执行“gimp”并不会启动 Gimp,所以我相信脚本中无法识别我的别名。因此,要与我的 Python 命令行参数一起启动 Gimp,我这样做:
/applications/gimp-2.10.app/contents/macos/gimp -idf --batch-interpreter python-fu-eval -b "import sys;sys.path=['.']+sys.path;import OAFE_PARAM;OAFE_PARAM.open_add_flatten_export('/Users/TimB/Desktop/xcftemplate.xcf','/Users/TimB/Desktop/jpg_to_add.jpg',2060,410,'/Users/TimB/Desktop/')" -b "pdb.gimp_quit(1)"
这不起作用。我的命令行参数被忽略,我看到一条消息“GIMP-Warning: The batch interpreter 'python-fu-eval' is not available. Batch mode disabled.”
为了排除故障,我尝试从 shell 脚本启动 Gimp UI,但即使这样也无法正常工作。它以破碎的图标奇怪地加载(见下图)。我能做些什么来解决这个问题?我在尝试启动 Gimp 时做错了什么吗?
这是我启动 Gimp 失败的脚本:
#!/bin/bash
arg1="/Users/TimB/Desktop/xcf_template.xcf" #XCF file to open
arg2="/Users/TimB/Desktop/jpg_to_add.jpg" # JPG to insert
arg3=2060 # x_offset
arg4=410 # y_offset
arg5="/Users/TimB/desktop/" # save location
echo
echo "arg1 is" $arg1
echo "arg2 is" $arg2
echo "arg3 is" $arg3
echo "arg4 is" $arg4
echo "arg5 is" $arg5
/applications/gimp-2.10.app/contents/macos/gimp -idf --batch-interpreter python-fu-eval -b "import sys;sys.path=['.']+sys.path;import OAFE_PARAM;OAFE_PARAM.open_add_flatten_export('/Users/TimB/Desktop/xcftemplate.xcf','/Users/TimB/Desktop/')" -b "pdb.gimp_quit(1)"
更新 (3-27-2021): 我按照 Mark 的建议删除了我的别名,确保 /usr/local/bin 在我的 PATH 上,然后我用 sudo ln -s /applications/gimp-2.10.app/contents/macos/gimp /usr/local 创建了一个符号链接/bin/gimp.这仍然让我通过在终端中键入“Gimp”来启动 Gimp,但它仍然在 shell 脚本中失败。我收到这条消息。
shell 脚本非常简单:
#!/bin/bash
gimp
这是我得到的错误:
../../../../gtk/source/babl-0.1.78/babl/babl-internal.h:214 void babl_log(const char *,...)()
WARNING: the babl installation seems broken,no extensions found in queried
BABL_PATH (/Users/distiller/gtk/inst/lib/babl-0.1) this means no SIMD/instructions/special case fast paths and
only slow reference conversions are available,applications might still
run but software relying on babl for conversions will be slow
2021-03-27 11:27:22.180 gimp[85955:1451980] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
Cannot spawn a message bus without a machine-id: Unable to load /var/lib/dbus/machine-id or /etc/machine-id: Failed to open file “/var/lib/dbus/machine-id”: No such file or directory
../../../../gtk/source/babl-0.1.78/babl/babl-internal.h:222 void babl_fatal(const char *,...)()
const Babl *babl_format(const char *)("CIE Lab double"): not found
sh: gdb: command not found
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。