相关疑难解决方法(0)

在python中从PDF中提取图像而不重新采样?

如何从原始分辨率和格式中提取pdf文档中的所有图像?(意思是提取tiff为tiff,jpeg为jpeg等,无需重新采样).布局是不重要的,我不在乎是源图像位于页面上.

我正在使用python 2.7,但如果需要可以使用3.x.

python pdf image extract pypdf

61
推荐指数
13
解决办法
7万
查看次数

引发 RuntimeError(f"目录 '{directory}' 不存在") RuntimeError: 导入 fitz 时目录 'static/' 不存在

当我运行 extract_img.py 文件时出现此错误:

\n
\n

运行时错误(f\xe2\x80\x9c目录'{目录}'不存在\xe2\x80\x9d)
\n运行时错误:导入fitz时目录'static/'不存在

\n
\n

我不明白为什么这会向我发回此错误消息。\n我之前看到过处理此主题的对话,但我不明白解决方案。你可以帮帮我吗?

\n

此文件旨在从 PDF 文件中提取某些图像(某些文件中的图像)。

\n
from os import chdir\nimport shutil, os\nimport io\nfrom PIL import Image\nimport fitz\nfrom unif_noun import unif_noun #other file python for change file noun.\n\ndef execute_func(rootdir):\nfor subdir, dirs, files in os.walk(rootdir):\n    for file in files:\n        filepath = subdir + os.sep + file\n        if filepath.endswith(".pdf"):\n            #extract(f"{filepath}")\n            # open the file\n            pdf_file = fitz.open(file)\n            images = list()\n            for page_index in range(len(pdf_file)):\n                # get the page itself\n                page = pdf_file[page_index]\n                image_list = …
Run Code Online (Sandbox Code Playgroud)

python

21
推荐指数
2
解决办法
3万
查看次数

标签 统计

python ×2

extract ×1

image ×1

pdf ×1

pypdf ×1