如何从原始分辨率和格式中提取pdf文档中的所有图像?(意思是提取tiff为tiff,jpeg为jpeg等,无需重新采样).布局是不重要的,我不在乎是源图像位于页面上.
我正在使用python 2.7,但如果需要可以使用3.x.
当我运行 extract_img.py 文件时出现此错误:
\n\n\n运行时错误(f\xe2\x80\x9c目录'{目录}'不存在\xe2\x80\x9d)
\n
\n运行时错误:导入fitz时目录'static/'不存在
我不明白为什么这会向我发回此错误消息。\n我之前看到过处理此主题的对话,但我不明白解决方案。你可以帮帮我吗?
\n此文件旨在从 PDF 文件中提取某些图像(某些文件中的图像)。
\nfrom 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)