英文:
How to properly use file_raw_save via Python (GIMP PDB Procedure)
问题
以下是您提供的代码部分的翻译:
Plugin code:
def save_aci(save_img, filename):
img = save_img
filename = filename.strip()
pdb.file_raw_save(img, img.layers[0], filename, filename)
register(
"python_fu_save_aci",
"导出到ACI文件",
"将图像导出到ACI文件,如果存在LOD,则包含LOD",
"作者",
"作者",
"2023",
"保存ACI文件",
"GRAYA", # 目前仅支持从灰度图像(带有alpha通道)导出到(RG_88).aci格式
[
(PF_IMAGE, "save_img", "要保存的图像", None),
(PF_FILE, "filename", "完整文件名", None),
],
[],
save_aci, menu="<Image>/File/")
main()
运行GIMP插件时的输出:
/home/astro/.gimp-2.8/plug-ins/testplugin.py: 致命错误: 分段错误
^C/usr/lib64/gimp/2.0/plug-ins/script-fu 已终止: 中断
gimp: 已终止: 中断
/home/astro/.gimp-2.8/plug-ins/testplugin.py 已终止: 中断
/home/astro/.gimp-2.8/plug-ins/testplugin.py 已终止: 中断
[astro@cobalt-vm plug-ins]$ gimp
跟踪回溯(最近的调用最先):
File "/usr/lib64/gimp/2.0/python/gimpfu.py", line 736, in response
dialog.res = run_script(params)
File "/usr/lib64/gimp/2.0/python/gimpfu.py", line 361, in run_script
return apply(function, params)
File "/home/astro/.gimp-2.8/plug-ins/testplugin.py", line 128, in save_aci
pdb.file_raw_save(img, img.layers[0], filename, filename)
RuntimeError: 调用错误
请注意,这仅是提供给您的代码和输出的翻译,没有包含其他额外的内容。如果您需要任何其他帮助或建议,请随时提出。
英文:
While writing a GIMP 2.0 plugin via Python and gimpfu, I've run into pdb procedures such as file_raw_save(...). There arguments are laid out in the GIMP Procedure Browser (Help->Procedure Browser). But when calling them I receive very unhelpful output. My code and output is as follows:
Plugin code:
def save_aci(save_img, filename):
img = save_img
filename = filename.strip()
pdb.file_raw_save(img, img.layers[0], filename, filename)
register(
"python_fu_save_aci",
"Exports to ACI file",
"Exports image to ACI file, with LODs if they are present",
"Author",
"Author",
"2023",
"Save ACI File",
"GRAYA", # Currently only support export from Grayscale image (with alpha) to (RG_88) .aci format
[
(PF_IMAGE, "save_img", "Image to Save", None),
(PF_FILE, "filename", "Filename Fullpath", None),
],
[],
save_aci, menu="<Image>/File/")
main()
Output when running GIMP plugin:
/home/astro/.gimp-2.8/plug-ins/testplugin.py: fatal error: Segmentation fault
^C/usr/lib64/gimp/2.0/plug-ins/script-fu terminated: Interrupt
gimp: terminated: Interrupt
/home/astro/.gimp-2.8/plug-ins/testplugin.py terminated: Interrupt
/home/astro/.gimp-2.8/plug-ins/testplugin.py terminated: Interrupt
[astro@cobalt-vm plug-ins]$ gimp
Traceback (most recent call last):
File "/usr/lib64/gimp/2.0/python/gimpfu.py", line 736, in response
dialog.res = run_script(params)
File "/usr/lib64/gimp/2.0/python/gimpfu.py", line 361, in run_script
return apply(function, params)
File "/home/astro/.gimp-2.8/plug-ins/testplugin.py", line 128, in save_aci
pdb.file_raw_save(img, img.layers[0], filename, filename)
RuntimeError: calling error
After messing around with the filename arguments (perhaps one expected a path, and the other just a filename), the same output occurs. I was unable to find any documentation on this issue either.
My GIMP version is 2.8 and GIMP is running the script via Python 2.7.
Any suggestions?
答案1
得分: 1
你的代码在Gimp 2.10中运行正常。当我在我的Gimp 2.8中运行它时,我得到相同的调用错误。所以我认为这是后来修复的一个错误。
Gimp 2.10已经存在超过5年了,那么为什么还在使用Gimp 2.8?
英文:
Your code is OK and works in Gimp 2.10. I get the same calling error when I run it in my Gimp 2.8. So I assume it's a bug that was fixed later.
Gimp 2.10 has been around for over 5 years, so why Gimp 2.8?
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论