从类型为“”的图像中提取文本时出错PIL.PpmImagePlugin.PpmImageFile文件'用小矮人

2024-09-27 00:17:29 发布

您现在位置:Python中文网/ 问答频道 /正文

正在尝试使用pytesseract从类型为'PIL.PpmImagePlugin.PpmImageFile'的图像中提取文本。代码和错误如下

from pdf2image import convert_from_path
pages = convert_from_path('D:/pdf_csv/HealthCare/eRDS - ML/eRDS - ML/2001468/2001468,69,70.pdf',poppler_path='C:/Users/Hp/poppler-0.68.0/bin')
text = pyt.image_to_string(Image.open(pages[0]), lang='eng')

我得到的错误:

^{pr2}$

或者有什么方法可以将PpmImageFile转换成jpg或png格式


Tags: pathfrom图像类型convertpilpdf错误
1条回答
网友
1楼 · 发布于 2024-09-27 00:17:29

fmt='jpeg'fmt='png'添加到函数调用中,以从pdf2image获取非PPM图像。在

在你的例子中,改变

pages = convert_from_path('D:/pdf_csv/Health....001468,69,70.pdf',poppler_path='C:/Users/Hp/poppler-0.68.0/bin')

^{pr2}$

相关问题 更多 >

    热门问题