Skip to main content

Overview

The ImageConverter class converts image files to Markdown by extracting EXIF metadata (if exiftool is installed) and generating descriptions using multimodal LLMs (if configured). Particularly useful for generating accessible alt text and understanding image content.

Dependencies

Required: None (base install)
Optional: exiftool (external binary), OpenAI client for AI descriptions

Accepted Formats

list
  • image/jpeg
  • image/png
list
  • .jpg
  • .jpeg
  • .png

Class Definition

Methods

accepts()

Returns True for JPEG and PNG images.

convert()

Converts an image file to Markdown with metadata and optional AI description. Parameters:
BinaryIO
required
Binary stream of the image file
StreamInfo
required
Metadata about the file
str
Path to exiftool binary. If not provided, searches system PATH.
OpenAI client
OpenAI-compatible client for image description generation
str
Vision model to use (e.g., “gpt-4o”, “gpt-4-vision-preview”)
str
default:"Write a detailed caption for this image."
Custom prompt for image description
Returns: DocumentConverterResult with metadata and description as Markdown

Features

Metadata Extraction

If exiftool is available, extracts these fields:
  • ImageSize - Dimensions (e.g., “1920x1080”)
  • Title - Image title
  • Caption - Embedded caption
  • Description - Image description
  • Keywords - Keyword tags
  • Artist - Creator/photographer
  • Author - Author name
  • DateTimeOriginal - When photo was taken
  • CreateDate - When file was created
  • GPSPosition - Geographic coordinates

AI Description

When llm_client and llm_model are provided:
  1. Image converted to base64 data URI
  2. Sent to vision model with prompt
  3. Generated description added under ”# Description:” heading

Example Usage

Metadata Only

Output:

With AI Description

Output:

Custom exiftool Path

Implementation Details

Source Location

~/workspace/source/packages/markitdown/src/markitdown/converters/_image_converter.py:16

AI Description Pipeline

  1. Encode Image - Convert to base64
  2. Create Data URI
  3. Call Vision API - OpenAI-compatible chat completion with image

Error Handling

  • Metadata extraction failures are silent (no metadata included)
  • AI description failures return None (no description section)
  • Stream position preserved on errors

Use Cases

Accessibility

Photo Organization

Image Analysis

Limitations

  • Only JPEG and PNG formats supported
  • Other formats (GIF, WebP, TIFF, etc.) not handled
  • Metadata extraction requires external exiftool binary
  • AI descriptions require API access and incur costs
  • Large images may exceed API size limits