Extract PDF pages as images and store them in SQLite database with intelligent change detection.
scrawl2org is a Python command-line tool that processes PDF files and extracts each page as a PNG image, storing them in a SQLite database. It uses hash-based change detection to efficiently handle repeated processing of the same PDF files, only updating images when the source PDF or individual pages have changed.
- Efficient Change Detection: Uses SHA-256 hashes to detect changes at both file and page level
- SQLite Storage: Stores images as BLOBs with metadata (filename, page number, timestamps, hashes)
- Incremental Updates: Only processes changed pages, skipping unchanged content
- CLI Interface: Simple command-line interface with options for database path, force updates, and verbose output
- Automatic Cleanup: Removes page images when PDF page count decreases
# Install locally in development mode
make install
# Install globally as a tool
make install-tool
# Or install directly with uv
uv tool install .pip install -e .# Process a PDF file
scrawl2org document.pdf
# Use custom database location
scrawl2org document.pdf --database /path/to/custom.db
# Force reprocessing even if unchanged
scrawl2org document.pdf --force
# Verbose output
scrawl2org document.pdf --verbose# Process with all options
scrawl2org document.pdf -d custom.db -f -vThe tool creates two tables:
id: Primary keyfilename: Base filename of PDF file (no path)file_hash: SHA-256 hash of PDF contentlast_processed: Timestamp of last processing
id: Primary keypdf_file_id: Foreign key to pdf_filespage_number: Page number (0-based)image_data: PNG image data (BLOB)image_hash: SHA-256 hash of image datalast_updated: Timestamp of last update
See DATABASE_SCHEMA.md for complete schema documentation.
# Run all tests
make test
# Run tests with coverage
make test-coverage# Run linting (if ruff available)
make lint
# Format code (if ruff available)
make format# Clean build artifacts
make clean
# Install development dependencies
make install-dev- Python 3.8+
- PyMuPDF: PDF processing and image extraction
- Click: Command-line interface
- pytest: Testing framework (dev dependency)
- File Change Detection: Calculates SHA-256 hash of input PDF
- Database Lookup: Checks if file exists and hash has changed
- Page Processing: Extracts each page as 2x scaled PNG image
- Image Comparison: Compares image hashes to detect page-level changes
- Storage: Updates only changed images in SQLite database
- Cleanup: Removes images for pages that no longer exist
See LICENSE file for details.