hashgraph-online/awesome-codex-plugins / plugins/BestLemoon/codex-seo/skills/seo-image-gen
seo-image-gen
VerifiedAI image generation for SEO assets: OG/social preview images, blog hero images, schema images, product photography, infographics. Powered by Gemini via nanobanana-mcp. Requires banana extension installed. Use when user says "generate image", "OG image", "social preview", "hero image", "blog image", "product photo", "infographic", "seo image", "create visual", "image-gen", "favicon", "schema image", "pinterest pin", "generate visual", "banner", or "thumbnail".
| File | Kind | Size |
|---|---|---|
| LICENSE.txt | markdown | 142 B |
| SKILL.md | skill md | 8.1 KB |
| references/cost-tracking.md | markdown | 1.4 KB |
| references/gemini-models.md | markdown | 7.5 KB |
| references/mcp-tools.md | markdown | 3.7 KB |
| references/post-processing.md | markdown | 5.1 KB |
| references/presets.md | markdown | 2.2 KB |
| references/prompt-engineering.md | markdown | 20.2 KB |
| references/seo-image-presets.md | markdown | 3.9 KB |
| scripts/batch.pyexecutable | script | 3.1 KB |
| scripts/cost_tracker.pyexecutable | script | 6.2 KB |
| scripts/edit.pyexecutable | script | 4.5 KB |
| scripts/generate.pyexecutable | script | 5.4 KB |
| scripts/presets.pyexecutable | script | 4.9 KB |
| scripts/setup_mcp.py | script | 1.5 KB |
| scripts/validate_setup.py | script | 686 B |
scripts/generate.py
View on GitHub#!/usr/bin/env python3
"""Banana Codex - Direct API Fallback: Image Generation
Generate images via Gemini REST API when MCP is unavailable.
Uses only Python stdlib (no pip dependencies).
Usage:
generate.py --prompt "a cat in space" [--aspect-ratio 16:9] [--resolution 1K]
[--model MODEL] [--api-key KEY] [--thinking LEVEL] [--image-only]
"""
import argparse
import base64
import json
import os
import sys
import urllib.request
from datetime import datetime
from pathlib import Path
DEFAULT_MODEL = "gemini-3.1-flash-image-preview"
DEFAULT_RESOLUTION = "1K"
DEFAULT_RATIO = "1:1"
OUTPUT_DIR = Path.home() / "Documents" / "nanobanana_generated"
API_BASE = "https://generativelanguage.googleapis.com/v1beta/models"
VALID_RATIOS = {"1:1", "16:9", "9:16", "4:3", "3:4", "2:3", "3:2",
"4:5", "5:4", "1:4", "4:1", "1:8", "8:1", "21:9"}
VALID_RESOLUTIONS = {"512", "1K", "2K", "4K"}
def generate_image(prompt, model, aspect_ratio, resolution, api_key,
thinking_level=None, image_only=False):
"""Call Gemini API to generate an image."""
url = f"{API_BASE}/{model}:generateContent?key={api_key}"
modalities = ["IMAGE"] if image_only else ["TEXT", "IMAGE"]
body = {
"contents": [{"parts": [{"text": prompt}]}],
"generationConfig": {
"responseModalities": modalities,
"imageConfig": {
"aspectRatio": aspect_ratio,
"imageSize": resolution,
},
},
}
if thinking_level:
body["generationConfig"]["thinkingConfig"] = {"thinkingLevel": thinking_level}
data = json.dumps(body).encode("utf-8")
req = urllib.request.Request(
url,
data=data,
headers={"Content-Type": "application/json"},
method="POST",
)
try:
with urllib.request.urlopen(req, timeout=120) as resp:
result = json.loads(resp.read().decode("utf-8"))
except urllib.error.HTTPError as e:
error_body = e.read().decode("utf-8") if e.fp else ""
print(json.dumps({"error": True, "status": e.code, "message": error_body}))
sys.exit(1)
except urllib.error.URLError as e:
print(json.dumps({"error": True, "message": str(e.reason)}))
sys.exit(1)
# Extract image from response
candidates = result.get("candidates", [])
if not candidates:
finish_reason = result.get("promptFeedback", {}).get("blockReason", "UNKNOWN")
print(json.dumps({"error": True, "message": f"No candidates returned. Reason: {finish_reason}"}))
sys.exit(1)
parts = candidates[0].get("content", {}).get("parts", [])
image_data = None
text_response = ""
for part in parts:
if "inlineData" in part:
image_data = part["inlineData"]["data"]
elif "text" in part:
text_response = part["text"]
if not image_data:
finish_reason = candidates[0].get("finishReason", "UNKNOWN")
print(json.dumps({"error": True, "message": f"No image in response. finishReason: {finish_reason}"}))
sys.exit(1)
# Save image
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S_%f")
filename = f"banana_{timestamp}.png"
output_path = (OUTPUT_DIR / filename).resolve()
with open(output_path, "wb") as f:
f.write(base64.b64decode(image_data))
return {
"path": str(output_path),
"model": model,
"aspect_ratio": aspect_ratio,
"resolution": resolution,
"text": text_response,
}
def main():
parser = argparse.ArgumentParser(description="Generate images via Gemini REST API")
parser.add_argument("--prompt", required=True, help="Image generation prompt")
parser.add_argument("--aspect-ratio", default=DEFAULT_RATIO, help=f"Aspect ratio (default: {DEFAULT_RATIO})")
parser.add_argument("--resolution", default=DEFAULT_RESOLUTION, help=f"Resolution: 512, 1K, 2K, 4K (default: {DEFAULT_RESOLUTION})")
parser.add_argument("--model", default=DEFAULT_MODEL, help=f"Model ID (default: {DEFAULT_MODEL})")
parser.add_argument("--api-key", default=None, help="Google AI API key (or set GOOGLE_AI_API_KEY env)")
parser.add_argument("--thinking", default=None, choices=["minimal", "low", "medium", "high"], help="Thinking level")
parser.add_argument("--image-only", action="store_true", help="Return image only (no text)")
args = parser.parse_args()
if args.aspect_ratio not in VALID_RATIOS:
print(json.dumps({"error": True, "message": f"Invalid aspect ratio '{args.aspect_ratio}'. Valid: {sorted(VALID_RATIOS)}"}))
sys.exit(1)
if args.resolution not in VALID_RESOLUTIONS:
print(json.dumps({"error": True, "message": f"Invalid resolution '{args.resolution}'. Valid: {sorted(VALID_RESOLUTIONS)}"}))
sys.exit(1)
api_key = args.api_key or os.environ.get("GOOGLE_AI_API_KEY") or os.environ.get("GOOGLE_API_KEY")
if not api_key:
print(json.dumps({"error": True, "message": "No API key. Set GOOGLE_AI_API_KEY env or pass --api-key"}))
sys.exit(1)
result = generate_image(
prompt=args.prompt,
model=args.model,
aspect_ratio=args.aspect_ratio,
resolution=args.resolution,
api_key=api_key,
thinking_level=args.thinking,
image_only=args.image_only,
)
print(json.dumps(result, indent=2))
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |