我刚刚整理了一个关于图形设计的答案 (https://graphicdesign.stackexchange.com/questions/53919/editing-several-hundred-images-gimp/53965#53965),它旨在作为没有编程技能的人的 GIMP 自动化入门 -
它也应该有助于理解 Python-fu。
在同样的答案上,有官方文档的链接,以及如何创建小脚本的一个示例。您应该让他们浏览 GIMP 的 PDB,以了解您想要的确切收益。
但是,总而言之,您可以像这样创建 Python 文件:
from gimpfu import *
import glob
def auto():
for filename in glob(source_folder + "/*.png"):
img = pdb.gimp_file_load(source_folder + filename, source_folder + filename)
# place the PDB calls to draw on the image before your interation here
#disp = pdb.gimp_display_new(img)
pdb.gimp_image_merge_visible_layers(img, CLIP_TO_IMAGE)
pdb.gimp_file_save(img, img.layers[0], dest_folder + filename, dest_folder + filename)
# pdb.gimp_display_delete(disp)
pdb.gimp_image_delete(img) # drops the image from gimp memory
register("batch_process_for_blah",
"<short dexcription >Batch Process for Bla",
"<Extended description text>",
"author name",
"license text",
"copyright note",
"menu label for plug-in",
"", # image types for which the plug-in apply - "*" for all, blank for plug-in that opens image itself
[(PF_DIRNAME, "source_folder", "Source Folder", None),
(PF_DIRNAME, "dest_folder", "Dest Folder", None)], # input parameters -
[], # output parameters
menu="<Image>/File", # location of the entry on the menus
)
main()
要在 for 循环中找到所需的操作,请转到 Help->Procedure Browser - 或者更好的是,Filters->Python->Console 并点击 Browse - 几乎相同,但有一个“应用”按钮可以实现易于测试调用,并将其复制到您的插件代码中。