ImagiTranslate is an advanced application that translates text within images while faithfully preserving the original layout, colors, typography, and backgrounds.
Powered by the Gemini 3.1 Flash Image Preview model (also known as Nano Banana 2), it seamlessly replaces the original text with the translated text as if the image were natively created in the target language.
- Layout Preservation: Maintains fonts, colors, and the original visual hierarchy.
- Modern Web Interface: A sleek, glassmorphism-styled Web UI for quick, single-image translations.
- Batch Processing CLI: Command-line tool for translating entire folders of images at once.
- Secure: Your Gemini API key is required but never hardcoded. You can input it safely via the UI.
- Supported Formats:
.jpg,.jpeg,.png, and.webp.
- Python 3.9 or higher.
- A Gemini API Key with access to the
gemini-3.1-flash-image-previewmodel.
Clone the repository and install the dependencies:
git clone https://github.com/SmartSolarium/ImagiTranslate.git
cd ImagiTranslate
pip install -r requirements.txtThe easiest and most interactive way to use ImagiTranslate is through its web interface.
- Start the Flask server:
python app.py
- Open your browser and navigate to:
http://localhost:5000 - Upload an image, select your languages, securely paste your Gemini API Key, and click "Translate"!
For processing multiple files simultaneously, you can use the CLI script.
- (Optional) Set your API key as an environment variable to avoid entering it every time:
export GEMINI_API_KEY="your_api_key_here"
- Place your source images in an
input/folder. - Run the script specifying the target language (e.g., Italian):
python image_translator.py --target-lang "Italiano" - The translated images will be saved in the
output/folder.
| Flag | Name | Description | Default |
|---|---|---|---|
-i |
--input |
Folder containing source images | ./input |
-o |
--output |
Folder to save translated images | ./output |
-s |
--source-lang |
Source language (e.g., "English") | auto-detect |
-t |
--target-lang |
Target language (e.g., "French") | Required |
Example:
python image_translator.py -i ./my_images -o ./translated -s "English" -t "Spanish"- As an advanced visual generation model, translation speed and output quality depend heavily on the complexity of the image and current server loads.
- The model aims to achieve identical layouts, but very complex graphical text or low-resolution inputs may yield varying results.