如何在 Gimp 插件中调用外部命令?

How to call an external command in Gimp Plugin?

如何使用外部命令在 gimp 中编辑图片,然后 return 在插件或脚本中将结果发送到舞台。

shell 脚本中的示例:

魔法 label.gif +哑光
( +clone -shade 110x90 -normalize -negate +clone -compose Plus -composite)
(-clone 0 -shade 110x50 -normalize -channel BG -fx 0 +channel -matte)
-delete 0 +swap -compose 相乘 -

上面的命令(imagemagick 应用程序)创建了一个 gif,我想放回 gimp 阶段。可能是其他简单的选项或应用程序,但我需要 return 编辑回 gimp。 Python,脚本傅?非常感谢。

enter image description here

如果 GIMP 将采用标准输入,则使用 GIMP XCF 文件格式从 ImageMagick 传输到 GIMP。

magick label.gif +matte 
( +clone -shade 110x90 -normalize -negate +clone -compose Plus -composite ) 
( -clone 0 -shade 110x50 -normalize -channel BG -fx 0 +channel -matte ) 
-delete 0 +swap -compose Multiply XCF:- | GIMP -

有一个shellout.py Gimp plugin floating around可以借用代码。通常:

  • 将图层导出到临时文件(如果处理整个图像,可能需要执行 pdb.gimp_layer_new_from_visible()
  • 使用 subprocess.Popen() 和参数列表
  • 调用可执行文件
  • 使用 pdb.gimp_file_load_layer()
  • 将结果加载为新图层