【问题标题】:Calling gimp_image_convert_indexed with a custom palette, palette cant be found使用自定义调色板调用 gimp_image_convert_indexed,无法找到调色板
【发布时间】:2021-05-09 08:16:22
【问题描述】:

我正在制作一个脚本来将任何图像限制为 3 种颜色(用于在程序中显示到电子墨水显示器)。我想使用 GIMP 的 gimp_image_convert_indexed 函数 bc Wand 和 PIP 的 .quantize 不能按照我想要的方式工作并且看起来不太好。这是一个无头的 raspi 零。

当我使用 gimp -idf --batch-interpreter python-fu-eval -b 'import sys;sys.path=["."]+sys.path;import colorindex;colorindex.python_colorindex("gimptemp.jpg")' -b 'pdb.gimp_quit(1)' 调用脚本时,它给了我错误:

GIMP-Error: Calling error for procedure 'gimp-image-convert-indexed':
Palette 'E-Ink' not found

Traceback (most recent call last):
  File "/usr/lib/gimp/2.0/python/gimpfu.py", line 827, in _run
    return apply(func, params[1:])
  File "/usr/lib/gimp/2.0/plug-ins/python-eval/python-eval.py", line 25, in code_eval
    exec code in globals()
  File "<string>", line 1, in <module>
  File "./colorindex.py", line 7, in python_colorindex
    pdb.gimp_image_convert_indexed(image, 1, 4, 3, FALSE, FALSE, "E-Ink")
RuntimeError: Palette 'E-Ink' not found
batch command experienced an execution error
gimp: GEGL-WARNING: (gegl-tile-handler-cache.c:977):gegl_tile_cache_destroy: runtime check failed: (g_queue_is_empty (&cache_queue))
EEEEeEeek! 2 GeglBuffers leaked

自定义调色板位于 GIMP 的调色板文件夹中(当我通过 UI 打开调色板时甚至可以识别它),为了安全起见,我将调色板的副本放在运行脚本的目录中。我尝试将文件的名称和调色板的名称设置为“eink”而不是“E-Ink”,它有同样的错误。当我指定文件路径(“/home/pi/.config/GIMP/2.10/palettes/E-Ink.gpl”)而不是“E-Ink”时,同样的事情发生了。

这里是 colorindex.py(gimp 脚本)

import os
from gimpfu import *
def python_colorindex(file):
    os.system("echo gimp")
    image = pdb.gimp_file_load(file, file, run_mode=RUN_NONINTERACTIVE)
    drawable = pdb.gimp_image_get_active_layer(image)
    pdb.gimp_image_convert_indexed(image, 1, 4, 3, FALSE, FALSE, "E-Ink")
    os.system("echo processed image")
    pdb.gimp_file_save(image, drawable, file, file)
    pdb.gimp_image_delete(image)
    print("Exit")

这里是showing the error and the paths to the palette

这里是showing gimp recognizing the palette(在同一台机器上运行,但通过 Xming 提供 GUI)

【问题讨论】:

    标签: python linux gimp palette gimpfu


    【解决方案1】:

    在您的命令行中,您指定了 -d 选项,告诉 GIMP 不要加载任何数据:即“不要加载画笔、渐变、调色板、图案……”因此您的脚本不会有您的调色板已加载。

    【讨论】:

    • 你是对的,以gimp -if --batch-interpreter python-fu-eval -b 'import sys;sys.path=["."]+sys.path;import colorindex;colorindex.python_colorindex("rbw2.jpg")' -b 'pdb.gimp_quit(1)' 运行它运行良好。但现在我有一个类似的问题。在 .py 文件中运行它:subprocess.run(["gimp", "-if", "--batch-interpreter", "python-fu-eval", "-b", "import sys;sys.path=['.']+sys.path;import colorindex;colorindex.python_colorindex('gimptemp.jpg')", "-b", "pdb.gimp_quit(1)"]) 会返回类似的错误,知道为什么吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-07
    • 2021-01-08
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 2020-04-28
    • 2015-05-31
    相关资源
    最近更新 更多