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/edit.py
View on GitHub#!/usr/bin/env python3
"""Banana Codex - Direct API Fallback: Image Editing
Edit images via Gemini REST API when MCP is unavailable.
Uses only Python stdlib (no pip dependencies).
Usage:
edit.py --image path/to/image.png --prompt "remove the background"
[--model MODEL] [--api-key KEY]
"""
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"
OUTPUT_DIR = Path.home() / "Documents" / "nanobanana_generated"
API_BASE = "https://generativelanguage.googleapis.com/v1beta/models"
def edit_image(image_path, prompt, model, api_key):
"""Call Gemini API to edit an image."""
image_path = Path(image_path).resolve()
if not image_path.exists():
print(json.dumps({"error": True, "message": f"Image not found: {image_path}"}))
sys.exit(1)
# Read and encode image
with open(image_path, "rb") as f:
image_b64 = base64.b64encode(f.read()).decode("utf-8")
# Determine MIME type
suffix = image_path.suffix.lower()
mime_types = {".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg",
".webp": "image/webp", ".gif": "image/gif"}
mime_type = mime_types.get(suffix, "image/png")
url = f"{API_BASE}/{model}:generateContent?key={api_key}"
body = {
"contents": [
{
"parts": [
{"text": prompt},
{"inlineData": {"mimeType": mime_type, "data": image_b64}},
]
}
],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
},
}
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_edit_{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,
"source": str(image_path),
"text": text_response,
}
def main():
parser = argparse.ArgumentParser(description="Edit images via Gemini REST API")
parser.add_argument("--image", required=True, help="Path to input image")
parser.add_argument("--prompt", required=True, help="Edit instruction")
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)")
args = parser.parse_args()
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 = edit_image(
image_path=args.image,
prompt=args.prompt,
model=args.model,
api_key=api_key,
)
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 |