microsoft / microsoft/markitdown
[Bug]: PDF with embedded images fails conversion with ImageMagick policy error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 186k
- Forks
- 13.7k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 49
Description
环境信息
- 操作系统:Ubuntu 22.04 / macOS Sonoma
- 编程语言:Python 3.11
- markitdown版本:0.0.1.x
- 依赖版本:PyMuPDF 1.24.x / Pillow 10.x
- ImageMagick版本:6.9.x / 7.x
问题描述
包含嵌入式图片的PDF文件转换失败,ImageMagick安全策略阻止图片处理。
复现步骤
- 安装markitdown及相关依赖
- 准备包含嵌入式图片的PDF文件
- 运行:markitdown document.pdf
- 观察转换失败
预期行为
PDF应成功转换为Markdown,嵌入式图片应正确提取或内联。
实际行为
转换失败,ImageMagick报错。
报错日志
PolicyError: not authorized PDF at error/constitute.c/ReadImage/1243
最小复现代码
from markitdown import MarkItDown
md = MarkItDown()
result = md.convert(document_with_images.pdf)
print(result.text_content)
初步分析
ImageMagick默认安全策略禁止处理PDF文件,导致图片提取失败。
建议解决方案
- 在README中添加ImageMagick策略配置说明
- 提供自动配置脚本
- 添加替代方案:使用PyMuPDF直接提取图片
- 添加清晰的错误提示指导用户配置ImageMagick
Reported by Financier-Nuri from Unum AI
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with the markitdown CLI or MarkItDown().convert() using a PDF with embedded images, and inspect the reported ImageMagick PolicyError. Review the README, PyMuPDF and Pillow integration, and the PDF conversion path. Done means the issue has a documented or implemented resolution and PDF conversion no longer fails without clear user guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100