Dragneel/Manga_OCR
1
Manga OCR Translator
A powerful tool for translating manga, comics, and light novels using OCR (Optical Character Recognition) and machine translation.
Features
- Text Detection: Automatically detects text in manga images using PyTesseract
- Text Translation: Translates detected text to your preferred language
- PDF Support: Upload and translate entire PDF manga files
- URL Support: Translate manga directly from web URLs
- Modern UI: Clean, responsive Gumroad-like user interface
- Multiple Languages: Support for Japanese, Korean, Chinese, and more
Requirements
Before running the application, ensure you have the following installed:
- Python 3.8+
- Tesseract OCR - Must be installed and available in PATH
- Required Python packages from
requirements.txt
Installing Tesseract OCR
Windows
- Download the installer from UB Mannheim
- Install and add to PATH environment variable
- Default installation path:
C:\Program Files\Tesseract-OCR\tesseract.exe
macOS
brew install tesseractLinux (Ubuntu/Debian)
sudo apt update
sudo apt install tesseract-ocr
sudo apt install libtesseract-dev
# Install language data packages as needed
sudo apt install tesseract-ocr-jpn tesseract-ocr-chi-sim tesseract-ocr-korInstallation
- Clone the repository:
git clone https://github.com/yourusername/manga-ocr-translator.git
cd manga-ocr-translator- Install Python dependencies:
pip install -r requirements.txt- Set the Tesseract executable path in your environment (only if not in PATH):
# In your environment or at the top of utils/ocr.py
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe' # Windows exampleUsage
Starting the Server
Run the application:
python app.pyThen open a web browser and navigate to:
http://localhost:8000Using the Web Interface
- Access the main page at
http://localhost:8000 - Choose either URL or PDF upload method
- Configure source and target languages
- Submit for translation
- View and download the translated images
API Endpoints
The application also provides API endpoints for integration:
- POST /translate/url - Translate manga from a URL
- POST /translate/pdf - Translate manga from a PDF file
- GET /api/info - Get API information
Development
Project Structure
manga-ocr-translator/
├── app.py # Main FastAPI application
├── requirements.txt # Python dependencies
├── static/ # Static files
│ ├── translated/ # Translated images output
│ └── ui/ # UI assets
│ ├── index.html # Main UI page
│ ├── styles.css # CSS styles
│ └── scripts.js # JavaScript functionality
└── utils/ # Utility modules
├── ocr.py # OCR functionality using pytesseract
├── image.py # Image processing utilities
├── pdf.py # PDF handling
├── translation.py # Translation services
└── web.py # Web scraping utilitiesConfiguration
You can configure the application by modifying the following files:
- app.py: Main application settings
- utils/ocr.py: OCR settings and language mapping
- requirements.txt: Package dependencies
Troubleshooting
Common Issues
- Tesseract not found: Ensure Tesseract is installed and the correct path is set
- Missing language data: Install additional language data packages for Tesseract
- Slow performance: Consider using a GPU for faster processing
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
- PyTesseract for OCR capabilities
- FastAPI for the web framework
- Pillow for image processing
