A robust Python library and CLI to batch-generate images using the Google Gemini API, featuring resumable sessions and smart file management.
Project description
Gemini Image Generator
A robust Python library and command-line tool (CLI) to batch-generate images using the Google Gemini API.
This tool is designed for large-scale tasks, featuring resumable sessions via a manifest file, smart scanning for new files, and robust error handling.
Features
- Powerful CLI: Generate images directly from your terminal.
- Batch Processing: Scan directories (including subdirectories) for thousands of media files and generate a cover for each.
- Resumable & Robust: Uses a
manifest.jsonfile to track the status of every task. If the process is interrupted, it can be resumed from where it left off, never re-processing completed work. - Smart Scanning: Use
--force-scanto intelligently discover new files without losing the status of existing ones. - Verification: Use
--verifyto check for missing output images and automatically re-queue them for generation. - Flexible Configuration: Control models, prompts, and output settings via
config.yml.
Installation
pip install gemini-image-generator
Configuration
Before using the tool, you need to configure two files in your project directory:
1. .env file (for your API Key):
GOOGLE_API_KEY="YOUR_GOOGLE_AI_API_KEY_HERE"
2. config.yml file (for prompts and settings):
model: "gemini-2.5-flash-image-preview"
output_settings:
directory: "output_images"
filename_template: "{timestamp}_{prompt_brief}.png"
prompt_templates:
podcast_cover: "An abstract artwork for a podcast cover, inspired by the theme '{filename_stem}'. Primary visual elements: {keywords}. Style: minimalist, symbolic, impactful colors. NO text, NO letters, NO writing."
Usage
As a Command-Line Tool
The gemini-image command will be available after installation.
# Get help
gemini-image --help
# Generate a simple image from a prompt
gemini-image -p "A majestic lion in a futuristic city" -o "lion_v1.png"
# Use a prompt template from your config.yml
gemini-image -t "podcast_cover" -c "my_awesome_podcast.mp3"
As a Library
You can also import ImageGenerator into your own Python scripts.
from gemini_image_generator import ImageGenerator
try:
generator = ImageGenerator(config_path='path/to/your/config.yml')
# Simple text-to-image
generator.generate(prompt="A beautiful watercolor painting of a robot cat.")
# Using a template
generator.generate_from_template(
template_name='podcast_cover',
context={'filename_stem': 'The History of Rome', 'keywords': 'rome, history, podcast'}
)
except Exception as e:
print(f"An error occurred: {e}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gemini_image_generator-1.0.0.tar.gz.
File metadata
- Download URL: gemini_image_generator-1.0.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
515d08996c39088d772372be29d740949b5ce21685bdc5495160de9a130239f3
|
|
| MD5 |
1a6af85dbf342d05696d0b022d8619df
|
|
| BLAKE2b-256 |
c8489d89efb15b0f8ec3bb3f3441e62ade865b9cce0a94aece0293f191d29348
|
File details
Details for the file gemini_image_generator-1.0.0-py3-none-any.whl.
File metadata
- Download URL: gemini_image_generator-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a72f420f75b28b823cdda0a474ba9c29919a42cec8e5583f7a483daea5e6052f
|
|
| MD5 |
443b05999fee082e41da7dc60b57b7b0
|
|
| BLAKE2b-256 |
0547e5d096750d2be8fd91070c0a36f61162ce70e8a2fd7df93896fd4a938ed9
|