Overview
TheImageConverter 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
Optional:
exiftool (external binary), OpenAI client for AI descriptions
Accepted Formats
list
image/jpegimage/png
list
.jpg.jpeg.png
Class Definition
Methods
accepts()
True for JPEG and PNG images.
convert()
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
DocumentConverterResult with metadata and description as Markdown
Features
Metadata Extraction
Ifexiftool is available, extracts these fields:
ImageSize- Dimensions (e.g., “1920x1080”)Title- Image titleCaption- Embedded captionDescription- Image descriptionKeywords- Keyword tagsArtist- Creator/photographerAuthor- Author nameDateTimeOriginal- When photo was takenCreateDate- When file was createdGPSPosition- Geographic coordinates
AI Description
Whenllm_client and llm_model are provided:
- Image converted to base64 data URI
- Sent to vision model with prompt
- Generated description added under ”# Description:” heading
Example Usage
Metadata Only
With AI Description
Custom exiftool Path
Implementation Details
Source Location
~/workspace/source/packages/markitdown/src/markitdown/converters/_image_converter.py:16
AI Description Pipeline
-
Encode Image - Convert to base64
-
Create Data URI
-
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
exiftoolbinary - AI descriptions require API access and incur costs
- Large images may exceed API size limits