Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign up Reseting focus

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

This project provides a Python script that converts images and PDF files containing text into plain text using Optical Character Recognition (OCR). It can process individual files or entire directories, supporting various image formats and PDF files.

Notifications You must be signed in to change notification settings

Eisen9/Image-and-PDF-to-Text-Converter

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Go to file

Folders and files

Last commit message Last commit date

Latest commit

History

View all files

Repository files navigation

Image and PDF to Text Converter

This project provides a Python script that converts images and PDF files containing text into plain text using Optical Character Recognition (OCR). It can process individual files or entire directories, supporting various image formats and PDF files.

Features

Requirements

Installation

  1. Clone this repository or download the script.
  2. Install the required Python packages:
pip install -r requirements.txt 

Usage

Run the script from the command line:

python ocr.py path/to/file_or_directory [-o output_file.txt] 

Examples

  1. Process a single image file:
python ocr.py image.png 
python ocr.py document.pdf 
python ocr.py path/to/directory -o results.txt 

How It Works

  1. The script uses the pytesseract library, which is a Python wrapper for Google's Tesseract OCR engine, to extract text from images.
  2. For PDF files, it uses the pdf2image library to convert PDF pages to images, which are then processed by the OCR engine.
  3. When processing a directory, it identifies all supported file types and processes them sequentially.
  4. The extracted text is either printed to the console or saved to a specified output file.

Supported File Types

Troubleshooting

Contributing

Contributions to improve the script or extend its functionality are welcome. Please feel free to submit a pull request or open an issue to discuss potential changes/additions.

License

This project is open source and available under the MIT License.

About

This project provides a Python script that converts images and PDF files containing text into plain text using Optical Character Recognition (OCR). It can process individual files or entire directories, supporting various image formats and PDF files.