A minimal command line application for converting images and PDFs to text using Windows native OCR APIs.
The application is just a wrapper around the winocr Python package.
- Download the executable: Download the
winocr_cli.exe
file from the Releases section of this repository. - Open Command Prompt or PowerShell: Navigate to the directory where you downloaded the
winocr_cli.exe
file. - Run the command: Use the following command syntax:
winocr_cli.exe -l "en" -i \path\to\image.png -o \path\to\output.txt
- Replace
\path\to\image.png
with the path to your input image file. - Replace
\path\to\output.txt
with the path where you want to save the output text file. - Optionally, you can specify the language parameter
-l
(default is "en"). - To process multiple input and output files, you can specify multiple pairs of input-output using the same command format:
winocr_cli.exe -l "en" -i image1.png image2.png -o output1.txt output2.txt
Once the command is executed, the output text file(s) will be generated at the specified location(s).
- Clone the repository.
- Install dependencies: Navigate to the cloned directory and install the required dependencies.
- Run the script: In the directory root, run this script using Python:
python winocr_cli.py -l "en" -i \path\to\image.png -o \path\to\output.txt
If you are using venv
on Windows, in Powershell, you may have to run Set-ExecutionPolicy Unrestricted -Scope Process
before running venv\Scripts\activate
.
If the script runs as expected, you can now build the app.
- Build the app: Run
pyinstaller --onefile winocr_cli.py
to build the executable.
If you get an error saying: The term 'pyinstaller' is not recognized as the name of a cmdlet, function, script file, or operable program., try running python -m PyInstaller --onefile winocr_cli.py
instead.
(Required) For building the app -
winocr
pillow
(PIL)pdf2image
pyinstaller
(for creating the executable file)
(Optional) For running the app -
poppler
(for handling PDFs; runwinocr_cli.exe --setup
to download poppler in the default location)
- Ensure that the input image file exists and is accessible from the command line.
- The application bundles all necessary dependencies, so there's no need to install them separately.
- The executable might trigger security warnings on your machine. Feel free to bypass them to use the app. Or build it yourself from source.
- Language support is constrained by the languages available on your Windows installation.
Contributions are welcome! If you'd like to contribute to winocr_cli, please submit a pull request detailing the changes you made.
This project is licensed under the MIT License - see the LICENSE file for details.