A Python tool that converts Obsidian markdown notes containing embedded images into text-based notes and flashcards using Claude AI. This tool extracts mathematical formulas, diagrams, and other visual content from images and converts them into LaTeX and text format.
- Image-to-Text Conversion: Converts embedded images (PNG, JPEG, GIF, WebP) to text using Claude AI vision capabilities
- Multiple Markdown Formats: Supports both standard markdown (
) and Obsidian wiki-link (![[image.png]]) image formats - LaTeX Math Support: Automatically converts mathematical content to proper LaTeX formatting
- Flashcard Generation: Creates spaced repetition flashcards from processed notes
- Batch Processing: Process entire folders of markdown files at once
- Error Handling: Gracefully handles missing images and API errors
- Processing Reports: Generates detailed reports of successful and failed conversions
- Python 3.7 or higher
- Anthropic Claude API key
- Internet connection for API calls
Run the installation script:
chmod +x install_dependencies.sh
./install_dependencies.sh- Clone or download this repository
- Install required Python packages:
pip install anthropic python-dotenv pytest- Set up your environment variables:
# Create a .env file in the project root
echo "CLAUDE_API_KEY=your_api_key_here" > .env-
API Key Setup:
- Get your Claude API key from Anthropic Console
- Create a
.envfile in the project root directory - Add your API key:
CLAUDE_API_KEY=your_actual_api_key
-
Directory Structure:
your-project/ ├── input_notes/ # Your Obsidian markdown files │ ├── note1.md │ ├── note2.md │ └── Image Assets/ # Image files (or relative paths) │ ├── diagram1.png │ └── graph1.jpg └── processed_notes/ # Output directory (created automatically) ├── note1_complete.md ├── note2_complete.md ├── flashcards/ │ ├── note1_flashcards.md │ └── note2_flashcards.md └── processing_report.json
from note_converter import NoteConverter
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
api_key = os.getenv("CLAUDE_API_KEY")
# Initialize converter
converter = NoteConverter(api_key)
# Process all markdown files in a folder
results = converter.process_folder(
input_folder="./input_notes",
output_folder="./processed_notes"
)
print(f"Processed: {len(results['processed'])} files")
print(f"Failed: {len(results['failed'])} files")# Process a single markdown file
complete_note = converter.process_markdown_note("./input_notes/calculus.md")
# Generate flashcards from the complete note
flashcards = converter.markdown_to_flashcards(complete_note, "calculus")# Run the main script
python note_converter.pyMake sure to update the folder paths in the __main__ section of note_converter.py to match your setup.
- PNG (
.png) - JPEG (
.jpg,.jpeg) - GIF (
.gif) - WebP (
.webp)
- Standard Markdown:
 - Obsidian Wiki-links:
![[image.png]] - Relative Paths:
 - Image Assets Folder: Automatically looks in
Image Assets/subdirectory
For each processed note, the tool generates:
- Complete Note (
filename_complete.md): Original note with images replaced by extracted text - Flashcards (
filename_flashcards.md): Generated Q&A flashcards for spaced repetition - Processing Report (
processing_report.json): Summary of successful and failed conversions
# Calculus Notes
The derivative of $x^2$ is shown in this diagram:

This is fundamental to understanding calculus.# Calculus Notes
The derivative of $x^2$ is shown in this diagram:
$$f'(x) = 2x$$
The graph shows the parabola $y = x^2$ and its derivative $y = 2x$, demonstrating how the slope of the tangent line at any point $(x, x^2)$ equals $2x$.
This is fundamental to understanding calculus.Q: What is the derivative of $x^2$?
A: $f'(x) = 2x$
---
Q: How does the derivative $2x$ relate to the original function $x^2$?
A: The derivative $2x$ gives the slope of the tangent line at any point on the parabola $y = x^2$.
---Run the comprehensive test suite:
# Run all tests
pytest test.py -v
# Run with detailed output
pytest test.py -v --tb=short
# Run specific test
pytest test.py::TestNoteConverter::test_extract_image_paths_standard_markdown -vThe test suite includes:
- Image path extraction (standard and Obsidian formats)
- Image-to-text conversion
- Markdown processing
- Flashcard generation
- Folder processing
- Error handling
The tool handles various error scenarios gracefully:
- Missing Images: Replaces with
[Image not found: filename] - API Errors: Replaces with
[Image conversion failed: filename] - Invalid Files: Logs errors and continues processing other files
- Network Issues: Provides detailed error messages
- Requires active internet connection for Claude API
- API usage costs apply (see Anthropic pricing)
- Large images may take longer to process
- Complex diagrams may not convert perfectly
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is open source. Please check with Anthropic's terms of service for API usage guidelines.
-
API Key Error:
- Verify your
.envfile contains the correct API key - Check that the key has proper permissions
- Verify your
-
Missing Images:
- Ensure image paths in markdown are correct
- Check that images exist in the specified directories
-
Import Errors:
- Run the installation script to ensure all dependencies are installed
- Verify Python version compatibility
-
Permission Errors:
- Ensure write permissions for output directories
- Check file permissions for input files
- Check the test files for usage examples
- Review the processing report JSON for detailed error information
- Ensure all file paths use forward slashes or proper Path objects