ocr-file
A powerful Python-based OCR file converter with Docker support for PDF and image processing
229
A powerful Python-based document converter application that performs Optical Character Recognition (OCR) on PDF documents and images, extracting text content with high accuracy.
⚠️ Important Notice: The previous image
truongginjs/ocr-fileis obsolete. Please use truongginjs/ocr-converter instead. All functionality remains the same - only the image name changed.
# Download and run the deployment script
curl -O https://raw.githubusercontent.com/truongginjs/ocr-file/main/deploy.sh
chmod +x deploy.sh
./deploy.sh
# Pull the latest image (with Vietnamese support)
docker pull truongginjs/ocr-file:latest
# Run the container
docker run -d \
--name ocr-converter \
-p 8000:8000 \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
truongginjs/ocr-file:latest
# Download docker-compose.yml
curl -O https://raw.githubusercontent.com/truongginjs/ocr-file/main/docker-compose.yml
# Start English API service
docker-compose up document-converter
# Start Vietnamese API service
docker-compose --profile vietnamese up document-converter-vie
# Use CLI for batch processing
docker-compose --profile cli run --rm document-converter-cli /app/input -o /app/output -l eng
Once running, the FastAPI service will be available at http://localhost:8000
# Process files directly (English default)
docker run --rm \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
truongginjs/ocr-file:latest
# Process with Vietnamese language support
docker run --rm \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
truongginjs/ocr-file:latest \
python converter.py /app/input -o /app/output -l vie
# Process with multiple languages
docker run --rm \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
truongginjs/ocr-file:latest \
python converter.py /app/input -o /app/output -l eng,vie
/app/input - Place your PDF files and images here for processing/app/output - Processed text files will be saved here# Place your PDF in the input directory
mkdir -p input output
cp your-document.pdf input/
# Run with English (default)
docker run --rm \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
truongginjs/ocr-file:latest
# Run with Vietnamese language
docker run --rm \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
truongginjs/ocr-file:latest \
python converter.py /app/input/your-document.pdf -o /app/output -l vie -f txt
# Run with both English and Vietnamese
docker run --rm \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
truongginjs/ocr-file:latest \
python converter.py /app/input/your-document.pdf -o /app/output -l eng,vie -f json
# Check the output directory for extracted text
ls output/
# Start the API server
docker run -d -p 8000:8000 --name ocr-api truongginjs/ocr-file:latest
# Upload and process via API (English default)
curl -X POST "http://localhost:8000/upload" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "[email protected]"
# Upload and process with Vietnamese language
curl -X POST "http://localhost:8000/upload" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "[email protected]" \
-F "language=vie"
# Visit API documentation
open http://localhost:8000/docs
You can easily add more languages by modifying the Dockerfile:
docker run --rm truongginjs/ocr-file:latest tesseract --list-langstesseract-ocr-fra \ # French
tesseract-ocr-deu \ # German
tesseract-ocr-spa \ # Spanish
tesseract-ocr-ita \ # Italian
tesseract-ocr-jpn \ # Japanese
# Single language
docker run --rm -v $(pwd)/input:/app/input -v $(pwd)/output:/app/output \
truongginjs/ocr-file:latest python converter.py /app/input/doc.pdf -l vie
# Multiple languages
docker run --rm -v $(pwd)/input:/app/input -v $(pwd)/output:/app/output \
truongginjs/ocr-file:latest python converter.py /app/input/doc.pdf -l eng,vie
The application can be configured through environment variables:
INPUT_DIR: Input directory path (default: /app/input)OUTPUT_DIR: Output directory path (default: /app/output)API_PORT: API server port (default: 8000)OCR_LANGUAGE: Default OCR language (default: eng)OCR_ENGINE: OCR engine to use (tesseract or easyocr, default: tesseract)docker run -d \
-p 8000:8000 \
-e OCR_LANGUAGE=vie \
-e OCR_ENGINE=tesseract \
-v $(pwd)/input:/app/input \
-v $(pwd)/output:/app/output \
truongginjs/ocr-file:latest
Input: PDF document with text and images Output: Clean text file with extracted content, maintaining structure and formatting where possible.
latest (Current): Vietnamese language support
tesseract-ocr-vie)v0.1: Initial release with core OCR functionality
This image is maintained and updated regularly. For issues or feature requests, please contact the maintainer.
Truong Nguyen
If this Docker image helped you, consider buying me a coffee!
Your support helps maintain and improve this project! 🙏
This Docker image contains open-source components. Please refer to individual component licenses for specific terms.
truongginjs/ocr-file:latest - Latest stable version with Vietnamese supporttruongginjs/ocr-file:0.2 - Version 0.2 with Vietnamese supporttruongginjs/ocr-file:0.1 - Version 0.1 (English only)Built with ❤️ for efficient document processing
1. Language not supported error
# Check available languages
docker run --rm truongginjs/ocr-file:latest tesseract --list-langs
# Verify you're using correct language codes
docker run --rm truongginjs/ocr-file:latest python converter.py /app/input/test.pdf -l eng
2. Permission denied on output directory
# Fix permissions
chmod 755 output/
sudo chown -R $USER:$USER output/
3. Container exits immediately
# Check logs
docker logs ocr-converter
# Run in interactive mode to debug
docker run -it --rm truongginjs/ocr-file:latest /bin/bash
4. API not accessible
# Check if container is running
docker ps
# Check port mapping
docker port ocr-converter
# Test API endpoint
curl http://localhost:8000/health
docker logs <container-name>docker run --rm truongginjs/ocr-file:latest tesseract --list-langshttp://localhost:8000/docs when service is runningContent type
Image
Digest
sha256:f2aac08cd…
Size
407 MB
Last updated
about 1 year ago
docker pull truongginjs/ocr-file