2

我有一个巨大的目录列表,其中包含每 2 个图像:1 个 jpg 文件和 1 个 png 文件;我想从外部脚本创建与 jpg 关联的所有 .xcf 作为第一层。在尝试使用 python 之后,我一直沉浸在方案解释和其他相关主题中......有人可以帮助我做出这样的命令并理解它吗?

4

1 回答 1

1

通常,对于每对图像,类似这样:

image=pdb.gimp_file_load(jpgImage,jpgImage)
layer=pdb.gimp_file_load_layer(image,pngImage)
image.add_layer(layer,0)
pdb.gimp_xcf_save(0,image,layer,outputImage,outputImage)

ofn -coalesce-images脚本做了一些非常相似的事情(堆叠在一个目录中找到的所有图像)......

要在 headless Gimp 中运行这样的东西,考虑一个 .py 将从某个指定的根目录运行:

def run(directory):
    # Iterates subdirs and creates images

这个 .py 不需要是正式的 python 插件(不需要 register() 任何东西)。然后您可以使用以下命令启动它:

Unix-ish:

gimp -idf --batch-interpreter python-fu-eval -b 'import sys; sys.path=["."]+sys.path;import batch;batch.run("/some/path")' -b 'pdb.gimp_quit(1)'

视窗:

gimp -idf --batch-interpreter python-fu-eval -b "import sys;sys.path=['.']+sys.path;import batch;batch.run('/some/path')" -b "pdb.gimp_quit(1)"

(这有点令人费解,因为 Linux 和 Windows 在命令行中处理引号和双引号的方式有些相反)。

于 2017-03-06T17:21:39.967 回答