Extract text from images and translate it to any language using Google's advanced Gemini 1.5 Pro model. This tool maintains original formatting, preserves special characters, and provides both GUI and CLI interfaces for maximum flexibility.
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Supported Languages
- Project Structure
- Output
- Troubleshooting
- Notes
- Contributing
- License
- π€ Advanced Text Extraction using Gemini 1.5 Pro AI model
- π¨ Format Preservation - Maintains original text formatting and structure
- π€ Special Character Support - Preserves special characters, numbers, and symbols
- π» Dual Interface - User-friendly GUI and powerful command-line interface
- π Multi-Language Support - Translate to 100+ languages
- ποΈ Real-time Preview - See your image before processing
- β±οΈ Progress Tracking - Monitor translation progress
- π High Accuracy - Enhanced accuracy for both text extraction and translation
- Python 3.7 or higher
- Google API Key for Gemini models (free tier available)
- Internet connection for API access
git clone https://github.com/AadhityaS-2124/Multi_Lingua_Snap.git
cd Multi_Lingua_Snappip install -r requirements.txt- Visit Google AI Studio
- Click "Get API Key"
- Create a new API key or use an existing one
- Copy the API key
Option 1: Environment Variable (Recommended for Security)
# On Windows
set GOOGLE_API_KEY=your_api_key_here
# On Linux/Mac
export GOOGLE_API_KEY=your_api_key_hereOption 2: Permanent Environment Variable
- Windows: Search "Environment Variables" β Add to System Variables
- Mac/Linux: Add to
~/.bashrc,~/.zshrc, or~/.profile:export GOOGLE_API_KEY=your_api_key_here
Option 3: Direct Configuration (Not Recommended)
You can modify the script to include your API key directly, but never commit this to shared repositories.
Run the graphical interface for an intuitive, easy-to-use experience:
python image_translator_gui.pyFeatures:
- Browse and select image files
- Real-time image preview
- Dropdown menu for language selection
- Progress indicator
- Copy translated text to clipboard
For automation and scripting:
python gemini_image_translator.py --image path/to/your/image.jpg --language "Spanish"| Parameter | Description | Example |
|---|---|---|
--image |
Path to the image file containing text | sample_image.jpg |
--language |
Target language for translation | "Spanish", "French", "Japanese" |
# Translate to Spanish
python gemini_image_translator.py --image document.jpg --language "Spanish"
# Translate to French
python gemini_image_translator.py --image receipt.png --language "French"
# Translate to Japanese
python gemini_image_translator.py --image menu.jpg --language "Japanese"The tool supports 100+ languages including:
- European: English, Spanish, French, German, Italian, Portuguese, Dutch, Polish, Swedish, Greek, Russian
- Asian: Chinese (Simplified & Traditional), Japanese, Korean, Hindi, Thai, Vietnamese, Indonesian, Tagalog
- Middle Eastern: Arabic, Hebrew, Farsi, Turkish
- And many more!
For a complete list, refer to Google's Supported Languages.
Multi_Lingua_Snap/
βββ gemini_image_translator.py # CLI tool for image translation
βββ image_translator_gui.py # GUI application
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ sample_image.jpg # (Optional) Example image for testing
The tool outputs:
- Original Text - Text as extracted from the image
- Translated Text - Translated content in your target language
=== Original Text ===
Hello, this is a sample document.
=== Translated Text (Spanish) ===
Hola, este es un documento de ejemplo.
| Issue | Solution |
|---|---|
API key not found |
Ensure GOOGLE_API_KEY environment variable is set. Restart your terminal after setting it. |
Invalid image format |
Supported formats: JPG, PNG, GIF, WebP. Ensure your image is in one of these formats. |
No text found in image |
Image may be too blurry or have low contrast. Try a clearer image with better lighting. |
API quota exceeded |
You've reached your daily API limit. Wait 24 hours or upgrade your API tier. |
Module not found error |
Run pip install -r requirements.txt to install all dependencies. |
Permission denied |
Ensure the image file is readable and you have access to it. |
For more detailed error messages, you can modify the scripts to enable debug logging:
import logging
logging.basicConfig(level=logging.DEBUG)- Image Quality: The accuracy of text extraction depends heavily on image clarity
- Best Practices: Use clear images with good contrast between text and background
- Performance: Processing time depends on image size and API response time
- Formatting: Original text formatting, special characters, and numbers are preserved
- API Costs: Check Google's Gemini API pricing for free tier limits and rates
- Batch Processing: For multiple images, consider scripting with a loop
Contributions are welcome! To contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please ensure your code follows PEP 8 standards and includes appropriate comments.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Google Gemini 1.5 Pro
- Python community for excellent libraries
For issues, questions, or suggestions:
- Open an Issue
- Check existing discussions for similar questions
Last Updated: 2026
Maintainer: AadhityaS-2124