microsoft / microsoft/markitdown

Feature Request: Save embedded images from PDFs as separate files with relative Markdown links

Open
#2,049 1 comment 5 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

Problem

When converting PDFs with embedded images to Markdown, markitdown currently either:

  • Truncates base64 data (showing ![](data:image/png;base64...)), or
  • Preserves full base64 inline (which makes the Markdown file very large and unsuitable for RAG/indexing)

For full-context RAG pipelines and document archival, I need:

  1. Embedded images extracted and saved as separate files (e.g. images/page3-figure1.png)
  2. Markdown references using relative paths: ![description](images/page3-figure1.png)
  3. Optional: image metadata/captions in front matter or inline comments
Use case
  • Converting technical documentation, datasheets, and PDFs with diagrams for AI/LLM ingestion
  • Preserving full document context including visual information
  • Keeping Markdown files lightweight and portable while still referencing images
Proposed behavior

Add a CLI flag and Python API option, for example:

markitdown document.pdf --extract-images --output-dir ./output
from markitdown import MarkItDown
md = MarkItDown(extract_images=True, output_dir="./output")
result = md.convert("document.pdf")
# result.markdown includes: 
# Actual image files saved to ./output/images/
Alternatives considered
  • Full base64 inline: makes files too large for indexing/LLM pipelines
  • Image descriptions only: loses visual context for diagrams, charts, schematics
  • Manual extraction: error-prone and not reproducible
Additional context
  • Related to issue #162 (closed) and PR #1140 (base64 preservation added)
  • Complements issue #1346 (LLM image descriptions for RAG)
  • Would benefit users working with schematics, datasheets, research papers, and technical documentation
Environment
  • markitdown version: 0.1.6
  • Python version: 3.11+
  • OS: macOS

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 at the MarkItDown constructor and the convert("document.pdf") entry point shown in the issue, then trace the PDF conversion path and the CLI command. Done means both interfaces support the requested image output directory and produce Markdown with relative links to extracted image files.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.