关于 json-prompting-for-nano-banana
json-prompting-for-nano-banana 将图像需求转换为 Nano Banana Pro(Gemini 3 Pro Image)使用的结构化 JSON 规格,适用于可控、可重复生成及定向修改,涵盖营销图、UI 模型、图表和社交媒体图片。
主要功能
- 01将需求归类为五种 JSON 结构
- 02用稳定标识符表示场景元素
- 03定义布局、样式和约束
- 04支持定向编辑与视觉变体
- 05生成并校验带有效引用的 JSON
适用场景
- 01按品牌约束描述产品图片
- 02指定包含屏幕和组件的 UI 模型
- 03描述流程图或架构图
- 04制作数值准确的图表或指定平台尺寸的图片
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ jawhnycooke/ claude-code-nano-banana --skill json-prompting-for-nano-banana安装后在 Claude Code 中输入/json-prompting-for-nano-banana确认已加载。
详细介绍
Nano Banana Pro 的 JSON 提示词
此技能可将自然语言描述转换为结构化 JSON 架构,从而精确控制使用 Nano Banana Pro(Gemini 3 Pro Image)生成图像。
何时使用此技能
当用户想要执行以下操作时,请使用此技能:
- 使用精确的产品规格创建营销图片(产品摄影、主视觉图)
- 设计具有明确布局、组件和配色系统的 UI 原型
- 构建需要清晰展示流程的信息图或示意图
- 生成数字和图表准确性至关重要的数据可视化
- 创建具有特定平台尺寸和叠加文字的社交媒体图片
- 生成具有可复现性的图像(相同规格 = 相同结果)
- 迭代调整特定元素,而不重新生成其他所有内容
- 在多次图像生成中保持品牌一致性
以下情况请勿使用此技能:
- 用户想要进行能带来意外结果的创意探索
- 用户更喜欢基于感觉的提示词
- 简单的自然语言提示词就足以满足需求
- 用户还没有明确自己实际想要什么
核心概念:控制句柄
JSON 提示词的强大之处在于控制句柄概念。每个重要元素都有一个稳定的标识符:
- 限定范围的编辑:只更改背景或灯光,不影响其他元素
- 移动摄像机:同一场景,不同视角
- 主题变体:相同结构,不同视觉风格
- A/B 测试:比较仅有一个变量不同的两个版本
五种架构类型
1. 营销图片(marketing_image)
用于产品图、主视觉图、品牌摄影和广告视觉内容。
主要部分:
subject:产品类型、名称、变体、物理属性(表面处理、尺寸)props:前景、中景和背景物体及其数量和位置environment:表面材质、背景颜色/纹理、氛围/情绪camera:角度、取景、焦距、景深lighting:主光、补光、轮廓光、色温brand:Logo 素材、主色、禁止更改的内容controls:迭代过程中可以或不可以更改的内容
2. UI/UX(ui_builder)
用于应用界面、仪表盘、网站和界面原型。
主要部分:
app:平台(Web/移动端/桌面端)、保真度级别、视口、主题tokens:颜色(十六进制值)、排版、边框圆角、间距比例screens:包含 ID、名称、用途和布局容器的屏幕数组components:包含屏幕分配、容器位置和属性的 UI 元素constraints:布局锁定、主题锁定、内容锁定
3. 示意图(diagram_spec)
用于流程图、架构图、流程图示和系统可视化。
主要部分:
canvas:尺寸、单位、流程方向semantics:示意图类型、主要关系、泳道nodes:包含 ID、标签、用途、位置和样式的节点数组edges:节点之间的连接及其标签和箭头样式groups:用于组织节点的泳道或集群constraints:布局锁定、自动路由权限
4. 数据可视化(data_viz)
用于数值准确性至关重要的图表、统计图和统计图形。
主要部分:
chart_type:条形图、折线图、饼图、散点图、面积图、树状图、热力图data_series[]:包含标签和值的数据点数组axes:X 轴和 Y 轴配置(标签、最小值/最大值、单位、网格线)annotations:标注、趋势线、数据标签、重点标记style:颜色、字体、图例位置constraints:必须按指定内容准确显示的数据值
5. 社交媒体图片(social_graphic)
适用于带有文字叠层和品牌元素的平台专属社交内容。
主要部分:
platform:目标平台(instagram_post、instagram_story、twitter_card、linkedin_post、youtube_thumbnail)dimensions:根据平台自动设置,也可自定义background:纯色、渐变、图片或图案text_layers[]:标题、副标题、正文、CTA,以及位置和样式brand:徽标位置、颜色、字体style:视觉基调(简约、醒目、活泼、专业)
翻译工作流
第 1 步:判断意图
根据用户的描述确定目标架构:
| 用户提到…… | 使用的架构 |
|---|---|
| 产品图、主视觉图、品牌摄影、营销活动 | marketing_image |
| 屏幕、按钮、仪表板、应用、导航、模型图 | ui_builder |
| 流程、过程、系统、节点、方框与箭头 | diagram_spec |
| 图表、数据、统计、指标、数字 | data_viz |
| Instagram、Twitter、LinkedIn、社交帖子、缩略图 | social_graphic |
如果意图不明确,请提出 1-2 个简短问题以便确认。
第 2 步:收集需求
营销图片:
- 主体(产品类型、名称、尺寸)
- 道具(以及摆放位置:前景、底座周围、背景)
- 环境(表面、背景、氛围)
- 相机角度和构图
- 光线方向和强度
- 品牌限制(徽标、颜色、不可更改的内容)
UI/UX:
- 平台(Web、移动端、桌面端)
- 屏幕数量及其用途
- 布局区域(顶部导航、侧边栏、内容区)
- 关键组件(图表、表格、表单、卡片)
- 配色方案或品牌指南
图表:
- 图表类型(流程图、架构图、泳道图、思维导图)
- 关键节点/步骤
- 连接和标签
- 分组或泳道
- 流程方向
数据可视化:
- 图表类型(柱状图、折线图、饼图、散点图等)
- 带有实际数值的数据系列
- 轴标签和范围
- 注释或标注
- 输出中是否必须显示精确数值
社交媒体图片:
- 目标平台(决定尺寸)
- 背景样式(纯色、渐变、图片)
- 文本内容(标题、副标题、CTA)
- 品牌元素(徽标、颜色)
- 视觉风格/氛围
第 3 步:生成 JSON
使用适当的根键构建完整的 JSON 对象。确保:
- 所有 ID 都唯一
- 所有引用都有效
- 必填字段均已填写
- 输出为有效 JSON(无注释、无尾随逗号)
第 4 步:提供后续步骤
告诉用户:
- 检查 JSON,确保其准确表达了自己的意图
- 复制整个 JSON
- 打开 Nano Banana Pro(使用“Thinking”模型的 Gemini 应用,或 Google AI Studio)
- 粘贴并附上指令:“将此规范渲染为高保真图片”
- 修改特定字段并重新渲染,逐步迭代
常用值参考
相机角度: front、three_quarter_front、three_quarter_back、side、top_down、low_angle、overhead
取景范围: extreme_close_up、close_up、medium_close、medium、medium_wide、wide
光照强度: very_low、low、medium、high、very_high
光照方向: left、right、front、back、top、three_quarter_left、three_quarter_right
表面材质: glossy、matte、marble、wood、concrete、fabric、metal、glass
UI 保真度: wireframe、low-fi、mid-fi、hi-fi
UI 平台: web、mobile、tablet、desktop
图表类型: flowchart、architecture、sequence、swimlane、mindmap、org_chart
节点角色: start、end、process、decision、database、actor、note
图表类型: bar、horizontal_bar、line、area、pie、donut、scatter、bubble、treemap、heatmap、radar
社交平台: instagram_post(1080x1080)、instagram_story(1080x1920)、twitter_card(1200x675)、linkedin_post(1200x627)、youtube_thumbnail(1280x720)、facebook_post(1200x630)
文本位置: top_left、top_center、top_right、center_left、center、center_right、bottom_left、bottom_center、bottom_right
完整 Schema 示例
营销图片示例
请求:“为一个名为 Aurora Lime 的青柠气泡水品牌拍摄主视觉。12 盎司罐装饮料置于反光表面上,周围摆放青柠片和冰块。深青绿色背景,戏剧性的侧光。”
输出:
{
"marketing_image": {
"meta": {
"spec_version": "1.0.0",
"title": "Aurora Lime Hero Can Shot",
"campaign": "aurora_lime_launch",
"brand_name": "Aurora Lime",
"usage_context": "web"
},
"subject": {
"type": "product_can",
"name": "Aurora Lime Seltzer",
"variant": "Original Lime",
"physical_properties": {
"volume_oz": 12,
"dimensions": "standard 12oz beverage can",
"finish": "matte"
}
},
"props": {
"foreground": [
{
"type": "lime_slice",
"count": 3,
"position": "front_left",
"notes": "fresh lime slices, visible pulp and rind"
}
],
"midground": [
{
"type": "ice_cube",
"count": 12,
"position": "around_base",
"notes": "partially melted, small reflections"
}
],
"background": []
},
"environment": {
"surface": {
"material": "glossy",
"reflection_strength": 0.7
},
"background": {
"color": "#003b47",
"texture": "smooth",
"effect": "bokeh_soft"
},
"atmosphere": {
"mood": "refreshing, premium, night-time bar feel",
"keywords": ["sparkling", "cool", "luminous", "evening"]
}
},
"camera": {
"angle": "three_quarter_front",
"framing": "medium_close",
"focal_length_mm": 50,
"depth_of_field": "medium"
},
"lighting": {
"key_light_direction": "right",
"key_light_intensity": "high",
"fill_light_direction": "left",
"fill_light_intensity": "low",
"rim_light": false,
"color_temperature": "neutral"
},
"brand": {
"logo_asset": "aurora_lime_logo.png",
"primary_colors": ["#00ffc2", "#003b47"],
"must_match_assets": ["aurora_lime_logo.png"],
"forbidden_changes": [
"do_not_change_logo",
"do_not_change_brand_name"
]
},
"controls": {
"lock_subject_geometry": true,
"lock_logo_and_label": true,
"allow_background_variation": false,
"allow_prop_relayout": "small_only"
}
}
}
UI/UX 示例
请求:“面向 Web 的营销分析仪表板。浅色主题,蓝色点缀。主仪表板包含 KPI 卡片、流量图表和营销活动表格。顶部导航栏带徽标,左侧边栏。”
输出:
{
"ui_builder": {
"meta": {
"spec_version": "1.0.0",
"name": "Acme Analytics Dashboard",
"description": "Marketing analytics dashboard",
"author": "",
"tags": ["analytics", "marketing", "dashboard"]
},
"app": {
"platform": "web",
"fidelity": "hi-fi",
"viewport": {
"width": 1440,
"height": 900
},
"theme": "light"
},
"tokens": {
"color": {
"primary": "#2563EB",
"background": "#F9FAFB",
"surface": "#FFFFFF",
"accent": "#10B981"
},
"typography": {
"font_family": "system_sans",
"headline_size": 20,
"body_size": 14
},
"radius": {
"sm": 4,
"md": 8,
"lg": 12
},
"spacing_scale": [0, 4, 8, 12, 16, 24, 32]
},
"screens": [
{
"id": "screen_dashboard",
"name": "Dashboard",
"role": "primary",
"layout": {
"containers": [
{
"id": "container_top_nav",
"type": "stack",
"subtype": "horizontal",
"region": "top_nav",
"children": ["comp_logo", "comp_avatar"]
},
{
"id": "container_sidebar",
"type": "stack",
"subtype": "vertical",
"region": "sidebar",
"children": ["comp_nav_list"]
},
{
"id": "container_content",
"type": "grid",
"subtype": "column",
"region": "main_content",
"children": ["comp_kpi_grid", "comp_traffic_chart", "comp_campaigns_table"]
}
]
}
}
],
"components": [
{
"id": "comp_logo",
"screen_id": "screen_dashboard",
"container_id": "container_top_nav",
"component_type": "logo",
"props": {"text": "Acme Analytics"},
"data_binding": null
},
{
"id": "comp_nav_list",
"screen_id": "screen_dashboard",
"container_id": "container_sidebar",
"component_type": "nav_list",
"props": {
"items": [
{"label": "Overview", "icon": "home", "active": true},
{"label": "Channels", "icon": "bar_chart"},
{"label": "Settings", "icon": "gear"}
]
},
"data_binding": null
},
{
"id": "comp_kpi_grid",
"screen_id": "screen_dashboard",
"container_id": "container_content",
"component_type": "kpi_grid",
"props": {
"columns": 3,
"cards": [
{"label": "Sessions", "value": "124,983"},
{"label": "Signups", "value": "3,942"},
{"label": "Conversion", "value": "3.2%"}
]
},
"data_binding": null
},
{
"id": "comp_traffic_chart",
"screen_id": "screen_dashboard",
"container_id": "container_content",
"component_type": "line_chart",
"props": {"title": "Daily Traffic (Last 30 Days)"},
"data_binding": null
},
{
"id": "comp_campaigns_table",
"screen_id": "screen_dashboard",
"container_id": "container_content",
"component_type": "data_table",
"props": {
"title": "Active Campaigns",
"columns": ["Campaign", "Spend", "Clicks", "CPC"]
},
"data_binding": null
}
],
"constraints": {
"layout_lock": true,
"theme_lock": false,
"content_lock": false
}
}
}
图表示例
请求:“展示用户注册流程的流程图:着陆页、注册表单、电子邮件验证判断、验证邮件、账户激活。从左到右排列。”
输出:
{
"diagram_spec": {
"meta": {
"spec_version": "1.0.0",
"title": "User Signup Flow",
"description": "End-to-end signup process",
"author": "",
"tags": ["signup", "user-flow"]
},
"canvas": {
"width": 1920,
"height": 600,
"unit": "px",
"direction": "left_to_right"
},
"semantics": {
"diagram_type": "flowchart",
"primary_relationship": "control_flow",
"swimlanes": []
},
"nodes": [
{
"id": "node_start",
"label": "Start",
"role": "start",
"lane": null,
"group_id": null,
"position": {"x": 50, "y": 260},
"size": {"width": 80, "height": 80},
"style": {
"shape": "ellipse",
"fill_color": "#10B981",
"border_color": "#059669"
},
"data": {}
},
{
"id": "node_landing",
"label": "Visit Landing Page",
"role": "process",
"lane": null,
"group_id": null,
"position": {"x": 200, "y": 250},
"size": {"width": 180, "height": 100},
"style": {
"shape": "rectangle",
"fill_color": "#FFFFFF",
"border_color": "#111827"
},
"data": {}
},
{
"id": "node_signup_form",
"label": "Complete Signup Form",
"role": "process",
"lane": null,
"group_id": null,
"position": {"x": 450, "y": 250},
"size": {"width": 180, "height": 100},
"style": {
"shape": "rectangle",
"fill_color": "#FFFFFF",
"border_color": "#111827"
},
"data": {}
},
{
"id": "node_email_valid",
"label": "Email Valid?",
"role": "decision",
"lane": null,
"group_id": null,
"position": {"x": 700, "y": 250},
"size": {"width": 120, "height": 100},
"style": {
"shape": "diamond",
"fill_color": "#FEF3C7",
"border_color": "#D97706"
},
"data": {}
},
{
"id": "node_send_verification",
"label": "Send Verification Email",
"role": "process",
"lane": null,
"group_id": null,
"position": {"x": 900, "y": 250},
"size": {"width": 180, "height": 100},
"style": {
"shape": "rectangle",
"fill_color": "#FFFFFF",
"border_color": "#111827"
},
"data": {}
},
{
"id": "node_activate",
"label": "Activate Account",
"role": "process",
"lane": null,
"group_id": null,
"position": {"x": 1150, "y": 250},
"size": {"width": 180, "height": 100},
"style": {
"shape": "rectangle",
"fill_color": "#D1FAE5",
"border_color": "#059669"
},
"data": {}
},
{
"id": "node_end",
"label": "End",
"role": "end",
"lane": null,
"group_id": null,
"position": {"x": 1400, "y": 260},
"size": {"width": 80, "height": 80},
"style": {
"shape": "ellipse",
"fill_color": "#111827",
"border_color": "#111827"
},
"data": {}
}
],
"edges": [
{"id": "edge_1", "from": "node_start", "to": "node_landing", "label": "", "style": {"line_type": "straight", "arrowhead": "standard"}},
{"id": "edge_2", "from": "node_landing", "to": "node_signup_form", "label": "", "style": {"line_type": "straight", "arrowhead": "standard"}},
{"id": "edge_3", "from": "node_signup_form", "to": "node_email_valid", "label": "", "style": {"line_type": "straight", "arrowhead": "standard"}},
{"id": "edge_4", "from": "node_email_valid", "to": "node_send_verification", "label": "Yes", "style": {"line_type": "straight", "arrowhead": "standard"}},
{"id": "edge_5", "from": "node_email_valid", "to": "node_signup_form", "label": "No", "style": {"line_type": "orthogonal", "arrowhead": "standard"}},
{"id": "edge_6", "from": "node_send_verification", "to": "node_activate", "label": "", "style": {"line_type": "straight", "arrowhead": "standard"}},
{"id": "edge_7", "from": "node_activate", "to": "node_end", "label": "", "style": {"line_type": "straight", "arrowhead": "standard"}}
],
"groups": [],
"legend": {
"items": [
{"label": "Process", "shape": "rectangle", "fill_color": "#FFFFFF"},
{"label": "Decision", "shape": "diamond", "fill_color": "#FEF3C7"},
{"label": "Success", "shape": "rectangle", "fill_color": "#D1FAE5"}
]
},
"constraints": {
"layout_lock": false,
"allow_auto_routing": true
}
}
}
示例 4:数据可视化(季度收入图表)
{
"data_viz": {
"meta": {
"spec_version": "1.0.0",
"title": "Q4 2024 Revenue by Region",
"description": "Bar chart comparing regional revenue performance",
"author": "Finance Team"
},
"chart_type": "bar",
"orientation": "vertical",
"canvas": {
"width": 1200,
"height": 800,
"background_color": "#FFFFFF"
},
"data_series": [
{
"id": "revenue_q4",
"label": "Q4 2024 Revenue",
"color": "#2563EB",
"data_points": [
{"label": "North America", "value": 4250000},
{"label": "Europe", "value": 3180000},
{"label": "Asia Pacific", "value": 2890000},
{"label": "Latin America", "value": 1420000},
{"label": "Middle East", "value": 890000}
]
},
{
"id": "revenue_q3",
"label": "Q3 2024 Revenue",
"color": "#93C5FD",
"data_points": [
{"label": "North America", "value": 3950000},
{"label": "Europe", "value": 2980000},
{"label": "Asia Pacific", "value": 2650000},
{"label": "Latin America", "value": 1280000},
{"label": "Middle East", "value": 750000}
]
}
],
"axes": {
"x_axis": {
"label": "Region",
"show_gridlines": false
},
"y_axis": {
"label": "Revenue (USD)",
"min": 0,
"max": 5000000,
"format": "currency_millions",
"show_gridlines": true,
"gridline_color": "#E5E7EB"
}
},
"annotations": [
{
"type": "data_label",
"show": true,
"position": "above",
"format": "$X.XM"
},
{
"type": "callout",
"target_series": "revenue_q4",
"target_point": "North America",
"text": "+7.6% vs Q3",
"style": "badge_green"
}
],
"legend": {
"position": "top_right",
"orientation": "horizontal"
},
"style": {
"font_family": "Inter",
"title_size": 24,
"label_size": 12,
"bar_width": 0.35,
"bar_gap": 0.1,
"corner_radius": 4
},
"constraints": {
"data_lock": true,
"exact_values": [4250000, 3180000, 2890000, 1420000, 890000],
"allow_style_changes": true
}
}
}
示例 5:社交媒体图片(Instagram 帖子)
{
"social_graphic": {
"meta": {
"spec_version": "1.0.0",
"title": "Product Launch Announcement",
"campaign": "spring_2025_launch",
"brand_name": "Acme Tech"
},
"platform": "instagram_post",
"dimensions": {
"width": 1080,
"height": 1080,
"unit": "px"
},
"background": {
"type": "gradient",
"gradient": {
"direction": "diagonal_bottom_right",
"colors": ["#1E3A8A", "#7C3AED", "#EC4899"]
},
"overlay": {
"type": "noise",
"opacity": 0.05
}
},
"text_layers": [
{
"id": "headline",
"content": "Introducing AcmePod Pro",
"position": "center",
"offset_y": -120,
"style": {
"font_family": "Montserrat",
"font_weight": "bold",
"font_size": 64,
"color": "#FFFFFF",
"text_align": "center",
"max_width": 900,
"line_height": 1.1
}
},
{
"id": "subhead",
"content": "Sound reimagined. Silence perfected.",
"position": "center",
"offset_y": 0,
"style": {
"font_family": "Montserrat",
"font_weight": "medium",
"font_size": 28,
"color": "#E0E7FF",
"text_align": "center",
"max_width": 800
}
},
{
"id": "cta",
"content": "Available March 15 →",
"position": "bottom_center",
"offset_y": -80,
"style": {
"font_family": "Montserrat",
"font_weight": "semibold",
"font_size": 22,
"color": "#FFFFFF",
"background_color": "rgba(255,255,255,0.15)",
"padding": "12px 24px",
"border_radius": 24,
"text_align": "center"
}
}
],
"visual_elements": [
{
"id": "product_image",
"type": "image_placeholder",
"position": "center",
"offset_y": 100,
"size": {"width": 400, "height": 400},
"description": "AcmePod Pro earbuds in floating arrangement",
"effects": ["drop_shadow", "subtle_glow"]
}
],
"brand": {
"logo": {
"asset": "acme_logo_white.png",
"position": "top_center",
"offset_y": 60,
"size": {"width": 120, "height": 40}
},
"primary_colors": ["#1E3A8A", "#7C3AED"],
"fonts": ["Montserrat"]
},
"style": {
"mood": "premium",
"keywords": ["modern", "sleek", "bold", "tech"]
},
"constraints": {
"lock_text_content": true,
"lock_brand_elements": true,
"allow_color_variation": false,
"allow_layout_adjustment": "minor"
}
}
}
迭代模式
用户有了基础 JSON 规范后,引导他们进行范围明确的更改:
仅更改光照(营销)
仅修改 lighting 部分。其他内容保持锁定。
仅更改相机角度(营销)
仅修改 camera.angle,并可选择修改 camera.focal_length_mm。
更换主题(UI)
替换令牌颜色,同时保持布局和组件不变。
添加组件(UI)
向 components 数组添加一个新对象,并使用有效的 screen_id 和 container_id。
更新数据值(数据可视化)
修改 data_series[].data_points 中的值,同时保持图表结构和样式不变。
更改图表类型(数据可视化)
将 chart_type 从 "bar" 换为 "line" 或 "area",同时保留数据和坐标轴。
调整平台尺寸(社交)
更改 platform 值,尺寸会自动调整。可能需要微调文本图层的位置。
更换配色方案(社交)
修改 background.gradient.colors 以及相应的文本颜色,营造新的氛围。
版本历史
- v1.1.0(2025-12-05):新增 data_viz 和 social_graphic Schema 类型
- v1.0.0(2025-12-05):首次发布,包含三种 Schema 类型(marketing_image、ui_builder、diagram_spec)