High-Performance Programmatic CLI & Chrome Extension Bridge for Gemini Web Image Generation
ImageGenPiper bridges a local Python asynchronous orchestrator with a Chrome Manifest V3 extension, allowing you to bulk generate images on gemini.google.com directly using your authenticated browser sessionβwith zero headless bot-fingerprinting, multi-turn visual character continuity, and no API rate-limit bottlenecks.
Below is the complete 10-panel survival story generated sequentially in a single persistent Gemini chat thread. Notice the consistent character features (the boy's tattered gray-blue tunic, messy hair, iron spear), color grading, and comic art style preserved across all 10 turns:
Prompt: "A breathtaking crystal dragon perched atop an obsidian mountain at sunset, 8k digital art"
Resolution:$1024 \times 559$ β’ Format: JPEG β’ Extracted via: Authenticated Browser Session Bridge
- π‘οΈ Zero Bot-Fingerprinting: Piggybacks directly on your authenticated Chrome session and cookies. No Playwright, Puppeteer, or CDP needed.
- π¨ Multi-Turn Visual Continuity: Runs batch prompts in a persistent Gemini thread so Imagen retains character features, art style, and color grading across sequential story panels.
- β‘ WebSocket Bridge (Manifest V3): Fast, persistent JSON-RPC communication between the Python CLI and Chrome with automatic reconnection and heartbeat keepalive.
- π― Anti-Fragile DOM Architecture: Multi-tier fallback selector engine (
SelectorMap) with synthetic event simulation and turn-scoped isolation. - π Atomic Deduplication & Persistence: In-memory hash locking prevents duplicate image writes during rapid rendering.
- π Unified Batch Manifest: Outputs clean sequentially numbered files (
01_title_<id>.jpg) and a single consolidatedmetadata.jsonmanifest per batch. - π Rich Terminal UI: Live status tables, real-time progress updates, and benchmark throughput reporting.
- π§ͺ 100% Test-Driven: Comprehensive unit, integration, and mock test suites (23 Python tests + 7 Extension tests).
# Clone repository and enter directory
cd ImageGenPiper
# Install Python package and dependencies
pip install -e .[dev]- Open Google Chrome and navigate to
chrome://extensions/. - Enable Developer mode in the top-right corner.
- Click Load unpacked and select the
extension/folder in this repository. - Open a tab with
https://gemini.google.com/appand ensure you are logged into your Google account.
You can run a quick connection test to verify that the CLI and your Chrome extension communicate:
imagegenpiper test-bridge(or python -m cli.main test-bridge)
imagegenpiper run --prompt "A breathtaking crystal dragon perched atop an obsidian mountain at sunset, 8k digital art" --output-dir ./outputsCreate a text file (e.g. prompts_the_scavengers_cache.txt) with titles in # comments:
# The Story: The Scavenger's Cache (10-part Series)
# Style: Detailed Stickman / Simple Comic Style
# Image 1: The Canyon Descent
Detailed stickman and simple comic art style, flat desaturated colors... Scene: A steep canyon wall. The boy rappelling down with guard spear...
# Image 2: The Sunken Vault
Detailed stickman and simple comic art style, flat desaturated colors... Scene: Discovering the rusted iron blast door...
# Image 3: The Broken Seal
Detailed stickman and simple comic art style, flat desaturated colors... Scene: Prying open the hatch with the triangular spear tip...
Run the batch generator:
imagegenpiper run --prompts-file prompts_the_scavengers_cache.txt --output-dir ./outputs/the_scavengers_cache --rate-limit 6| Option | Flag | Default | Description |
|---|---|---|---|
--prompt |
-p |
None |
Single prompt text to generate |
--prompts-file |
-f |
None |
Path to text file with prompts (one per line) |
--output-dir |
-o |
./outputs |
Directory where generated images and metadata are saved |
--rate-limit |
-r |
6.0 |
Max generation requests per minute (RPM) |
--concurrency |
-c |
1 |
Number of concurrent worker pipelines |
--timeout |
-t |
120 |
Timeout in seconds per prompt generation |
--new-chat-per-prompt |
False |
Reset to a fresh chat before each prompt (default: False, keeps persistent multi-turn thread) | |
--port |
8765 |
WebSocket bridge port |
Generated images are automatically saved with sequential index prefixes and descriptive scene slugs:
outputs/the_scavengers_cache/
βββ 2026-09-02/
βββ 01_the-canyon-descent_bbe710f0.jpg
βββ 02_the-sunken-vault_768a5483.jpg
βββ 03_the-broken-seal_abee6c33.jpg
βββ ...
βββ 10_the-salt-flat-crossing_0c2b2727.jpg
βββ metadata.json
The unified metadata.json captures complete batch benchmark metrics and image details:
{
"batch_id": "prompts_the_scavengers_cache",
"generated_at": "2026-09-02T12:33:37Z",
"total_prompts": 10,
"total_images_saved": 10,
"benchmark": {
"total_elapsed_seconds": 198.24,
"avg_seconds_per_image": 19.82,
"throughput_ipm": 3.03
},
"images": [
{
"index": 1,
"title": "The Canyon Descent",
"filename": "01_the-canyon-descent_bbe710f0.jpg",
"path": "outputs/the_scavengers_cache/2026-09-02/01_the-canyon-descent_bbe710f0.jpg",
"prompt": "Detailed stickman... Scene: A steep canyon wall...",
"job_id": "bbe710f0-...",
"mime_type": "image/jpeg",
"file_size_bytes": 142610,
"sha256": "a69191df8567c0e94501a46df2aa90f68abb256fd39c676741fa24492f1abb55",
"dimensions": { "width": 1024, "height": 559 },
"timestamp": "2026-09-02T12:30:57Z"
}
]
}This is normal when the Python CLI server is not running. The extension will automatically retry connecting with exponential backoff and will connect instantly the moment you start the CLI.
Ensure that:
- The extension is enabled in
chrome://extensions/. - Chrome is open and has a tab on
https://gemini.google.com/app.
If you make changes to extension files, run:
node scripts/build_extension.jsThen visit chrome://extensions/ and click the Reload (β») icon on the ImageGenPiper card.
# Run Python Unit and Integration Tests
pytest
# Run Extension Unit Tests
npm test









