我想在将图像发送到Tesseract进行OCR之前处理图像。
例如:
如何自动完成此过程?
答案 0 :(得分:3)
我刚刚在平面设计上汇总了一个答案(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
- 它几乎相同,但是&#34;申请&#34;按钮,可以轻松测试呼叫,并将其复制到您的插件代码。