Skip to main content

Convert PDFs and images into clean, LLM-compatible image formats

Project description

doc2vision

doc2vision is a robust Python utility designed to convert documents and image files — including PDF, JPG, PNG, and TIF — into clean, high-quality, RGB images optimized for multimodal LLM input (e.g., image + text AI models). It handles low-quality scans, rotated pages, and multi-page PDFs with ease.

Perfect for use in OCR preprocessing, AI pipelines, or anywhere clean document-to-image conversion is needed.


🚀 Features

  • ✅ Converts PDFs (including multipage) into individual high-quality images
  • ✅ Supports JPG, PNG, TIF, TIFF
  • ✅ Converts all output to standard RGB format
  • ✅ Optionally auto-corrects skewed scans
  • ✅ Gracefully handles edge cases like:
    • Low-resolution scans
    • Rotated or misaligned documents
    • Corrupt or unsupported files
    • Mixed DPI across pages

📦 Installation

pip install doc2vision

You may also need to install Poppler if you're using PDF input:

  • macOS: brew install poppler
  • Ubuntu/Debian: sudo apt-get install poppler-utils

🧠 Usage

from doc2vision import convert_to_llm_ready_images

# Basic usage
images = convert_to_llm_ready_images("example.pdf")

# With skew correction
images = convert_to_llm_ready_images("example.pdf", correct_skew=True)

# With resizing (preserving aspect ratio)
images = convert_to_llm_ready_images("example.pdf", resize_to=1500)

# Iterate over output Pillow images
for img in images:
    img.show()  # Or save, analyze, etc.

🛠️ Parameters

Parameter Type Default Description
file_path str Path to your input file (PDF, JPG, PNG, TIF)
correct_skew bool False If True, attempts to auto-detect and fix rotation
resize_to int None If set, resizes image height to this value (keeping aspect ratio)

📁 Output

Returns a list of Pillow Image.Image objects, one per page/image:

[List[PIL.Image.Image]]

All output images are:

  • RGB
  • Preprocessed (rotation + optional resize)
  • Clean and ready for AI or OCR pipelines

🤖 Perfect For

  • Feeding documents into multimodal LLMs
  • Preprocessing for OCR or Document AI
  • Converting messy scans into standardized visuals
  • AI agents needing consistent image inputs

📜 License

MIT License — feel free to use, extend, and contribute.


👨‍💻 Author

Built with 💙 by Russell Van Curen GitHub: @vancuren Website: vancuren.net

Changelog

0.1.0 - Initial release

0.1.1 - Updated project description and readme.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

doc2vision-0.1.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

doc2vision-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file doc2vision-0.1.1.tar.gz.

File metadata

  • Download URL: doc2vision-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for doc2vision-0.1.1.tar.gz
Algorithm Hash digest
SHA256 87f39eba9d7a3cd3b2bbf6f042ca81c2252d190203879e66719c86ee886678d1
MD5 5f86bfd1e0fab7c38d90a34001c946a2
BLAKE2b-256 77e313fc1e1aad604b2027473df79019cc790380f3e882d0ccb85fcb5061b3b4

See more details on using hashes here.

File details

Details for the file doc2vision-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: doc2vision-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for doc2vision-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2548cedf51861d05ab849191797737affee102fe161d48aef8d0756451aa1b2
MD5 5b44efae7579e0c9bfcb837055c277f6
BLAKE2b-256 1b7de03db3632bf506f6f7a04db509359171e7a0ff7c21382b7da4548ec6dad7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page