我想在批處理模式下執行一段Python代碼來編輯現有的Gimp文件。得到以下錯誤在批處理模式下的瘸子Python
批處理命令經歷執行錯誤: 錯誤:(1:1)的eval:未結合的變量:條命令行-執行
這裏是我使用的代碼:
#!/usr/bin/env python
from gimpfu import *
# the script
def my_tf_cmd_function(fle, fontname, fontsize) :
image = pdb.gimp_file_load(fle,fle)
drawable = pdb.gimp_image_get_active_layer(image)
image.undo_group_start()
foreground = gimp.get_foreground()
gimp.set_foreground(240,240,240)
textlayer1 = gimp.Layer(image, "Troo", drawable.width, drawable.height, RGBA_IMAGE, 100, NORMAL_MODE)
image.add_layer(textlayer1, 0)
pdb.gimp_drawable_fill(textlayer1, 3) # transparent fill
gimp.set_background(255, 255, 255)
gimp.set_foreground(240,240,240)
floattext = pdb.gimp_text_fontname(image, textlayer1, 200, 100, "T", 1, 1, fontsize, 1, fontname)
pdb.gimp_floating_sel_anchor(floattext)
gimp.set_foreground(foreground)
image.undo_group_end()
pdb.gimp_file_save(image, drawable, "/home/Downloads/img.xcf", "/home/Downloads/img.xcf")
return
# This is the plugin registration function
register(
"command_line_execution",
"My Command Line Attempt Python-Fu",
"This script does nothing and is extremely good at it",
"RC",
"RC",
"May 2013",
"<Image>/MyScripts/My Command Python-Fu",
"*",
[
(PF_STRING, "fle", "GlobPattern", "*.*"),
(PF_FONT, "fontname", "Foo font", "Arial"),
(PF_INT, "fontsize", "Foo font size", 18)
],
[],
my_tf_cmd_function,
)
main()
請幫忙。
你之前'/ home..' – mata
缺失報價jupp,將'/home/Downloads/img.xcf''改成'「/ home/Downloads/img。xcf「'這就是語法突出的美妙之處 –
感謝您的快速回復。file_save語句有正確的引號,但是我仍然得到錯誤。 –