当我尝试通过GIMP的gui运行以下python脚本时:
#!/usr/bin/env python
from gimpfu import *
def export_png(image, drawable, self):
filename=image.name
interlace=0
compression=0
bkgd=0
gama=0
off=0
phys=0
time=0
pdb.file_png_save(image, drawable, filename, raw_filename, interlace, compression, bkgd, gama, offs, phys, time)
register(
"python_fu_export_png",
"Exports the current image as png",
"Exports the current image as png",
"HHP",
"HHP",
"2017",
"<Image>/Image/Export as png",
"*",
[
(PF_IMAGE, "image", "takes current image", None),
(PF_DRAWABLE,"drawable", "input layer",None),
],
[],
export_png
)
main()我得到了这个错误:
Traceback (most recent call last):
File "/Applications/GIMP.app/Contents/Resources/lib/gimp/2.0/python/gimpfu.py", line 736, in response
dialog.res = run_script(params)
File "/Applications/GIMP.app/Contents/Resources/lib/gimp/2.0/python/gimpfu.py", line 361, in run_script
return apply(function, params)
TypeError: export_png() takes exactly 3 arguments (4 given)为什么会这样呢?我以为我只是把PF_Image和PF_DRAWABLE传递给函数,为什么它说我给了四个参数呢?
https://stackoverflow.com/questions/47463859
复制相似问题