在 python 中将图像转换为字符串后存档图像
Archive the Images after conversion of Image to string in python
我正在对图像 ('test.jpg') 进行 Tesseract-OCR。在 运行 下面的代码 (OCR) 部分之后,我将提取的字符串保存到 "OUTPUT.txt" 中。
现在我想存档图像 ("test.jpg") 你能帮我吗?
file='test.jpg'
def ocr(file):
foo = Image.open(file)
print(foo.size)
foo = foo.resize((2000,3000),Image.ANTIALIAS)
pytes=pytesseract.image_to_string(foo)
with open("OUTPUT.txt","w") as file:
file.write(str(pytes))
print(pytes)
ocr(file)
import os
from shutil import copyfile
archive_path = "path to your archive folder"
if not os.path.exists(archive_path):
os.makedirs(arichive_path)
copyfile("test.jpg", archive_path)
我正在对图像 ('test.jpg') 进行 Tesseract-OCR。在 运行 下面的代码 (OCR) 部分之后,我将提取的字符串保存到 "OUTPUT.txt" 中。 现在我想存档图像 ("test.jpg") 你能帮我吗?
file='test.jpg'
def ocr(file):
foo = Image.open(file)
print(foo.size)
foo = foo.resize((2000,3000),Image.ANTIALIAS)
pytes=pytesseract.image_to_string(foo)
with open("OUTPUT.txt","w") as file:
file.write(str(pytes))
print(pytes)
ocr(file)
import os
from shutil import copyfile
archive_path = "path to your archive folder"
if not os.path.exists(archive_path):
os.makedirs(arichive_path)
copyfile("test.jpg", archive_path)