microsoft / microsoft/markitdown

[Bug]: PDF with embedded images fails conversion with ImageMagick policy error

Open
#1,604 1 comment 0 reactions 0 assignees View on GitHub

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安全策略阻止图片处理。

复现步骤

  1. 安装markitdown及相关依赖
  2. 准备包含嵌入式图片的PDF文件
  3. 运行:markitdown document.pdf
  4. 观察转换失败

预期行为

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文件,导致图片提取失败。

建议解决方案

  1. 在README中添加ImageMagick策略配置说明
  2. 提供自动配置脚本
  3. 添加替代方案:使用PyMuPDF直接提取图片
  4. 添加清晰的错误提示指导用户配置ImageMagick

Reported by Financier-Nuri from Unum AI

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.