Skip to content

AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He

fix(tools):增强nano banana CLI错误处理及canvas回退机制,更新文档

hugohe380de987976cd
diff --git a/roles/Image_Generator.md b/roles/Image_Generator.md
index 927368ba..3a028ed6 100644
--- a/roles/Image_Generator.md
+++ b/roles/Image_Generator.md
@@ -377,7 +377,7 @@ subtle and elegant, suitable for presentation slide corners
- 可选环境变量:`GEMINI_BASE_URL`
- 命令格式:
```bash
- python tools/nano_banana_gen.py "你的提示词" --aspect_ratio 16:9 --image_size 4K --output 项目/images --filename cover_bg
+ python3 tools/nano_banana_gen.py "你的提示词" --aspect_ratio 16:9 --image_size 4K --output 项目/images --filename cover_bg
```
- **生成节奏控制(强制)**:
- 每次只执行一个生成命令,等待图片返回并确认文件落盘后,再执行下一条
diff --git a/tools/nano_banana_gen.py b/tools/nano_banana_gen.py
index acaf5e6b..3389e27c 100644
--- a/tools/nano_banana_gen.py
+++ b/tools/nano_banana_gen.py
@@ -15,8 +15,7 @@ Nano Banana Image Generator (Gemini Nano)
"""
import os
-
-import base64
+import sys
import argparse
import mimetypes
from google import genai
@@ -57,18 +56,18 @@ def generate(prompt: str, negative_prompt: str = None,
if not api_key:
print("Error: API Key not found. Please set GEMINI_API_KEY environment variable.")
- return
+ sys.exit(1)
# Validate aspect_ratio
if aspect_ratio not in VALID_ASPECT_RATIOS:
print(f"Error: Invalid aspect ratio '{aspect_ratio}'. Valid options: {VALID_ASPECT_RATIOS}")
- return
+ sys.exit(1)
# Validate image_size
size_upper = str(image_size).upper()
if size_upper not in VALID_IMAGE_SIZES:
print(f"Error: Invalid image size '{image_size}'. Valid options: {VALID_IMAGE_SIZES}")
- return
+ sys.exit(1)
# Configure client options
client_options = {'api_key': api_key}
diff --git a/tools/project_utils.py b/tools/project_utils.py
index 9d882794..41f01ca9 100644
--- a/tools/project_utils.py
+++ b/tools/project_utils.py
@@ -21,6 +21,48 @@ except ImportError:
'dimensions': '1280×720',
'viewbox': '0 0 1280 720',
'aspect_ratio': '16:9'
+ },
+ 'ppt43': {
+ 'name': 'PPT 4:3',
+ 'dimensions': '1024×768',
+ 'viewbox': '0 0 1024 768',
+ 'aspect_ratio': '4:3'
+ },
+ 'wechat': {
+ 'name': '微信公众号头图',
+ 'dimensions': '900×383',
+ 'viewbox': '0 0 900 383',
+ 'aspect_ratio': '2.35:1'
+ },
+ 'xiaohongshu': {
+ 'name': '小红书',
+ 'dimensions': '1242×1660',
+ 'viewbox': '0 0 1242 1660',
+ 'aspect_ratio': '3:4'
+ },
+ 'moments': {
+ 'name': '朋友圈/Instagram',
+ 'dimensions': '1080×1080',
+ 'viewbox': '0 0 1080 1080',
+ 'aspect_ratio': '1:1'
+ },
+ 'story': {
+ 'name': 'Story/竖版',
+ 'dimensions': '1080×1920',
+ 'viewbox': '0 0 1080 1920',
+ 'aspect_ratio': '9:16'
+ },
+ 'banner': {
+ 'name': '横版 Banner',
+ 'dimensions': '1920×1080',
+ 'viewbox': '0 0 1920 1080',
+ 'aspect_ratio': '16:9'
+ },
+ 'a4': {
+ 'name': 'A4 打印',
+ 'dimensions': '1240×1754',
+ 'viewbox': '0 0 1240 1754',
+ 'aspect_ratio': '√2:1'
}
}