Skip to Content

13b - 图像Prompt工程

本文是《AI Agent 实战手册》第 13 章第 2 节。 上一节:13a-图像生成工具对比 | 下一节:13c-API集成编程生成

概述

图像 Prompt 工程是 AI 图像生成中最核心的技能——同一个工具,好的 prompt 和差的 prompt 产出的图像质量可以天差地别。本节系统讲解图像 prompt 的结构化公式、六大核心技巧(“描述如何而非什么”、风格修饰符、负面 prompt、宽高比控制、构图与光照、镜头语言),并提供覆盖产品摄影、人像、风景、UI 原型、图标、社交媒体、品牌视觉、概念艺术、建筑可视化、美食摄影等 10+ 场景的即用型模板。


1. 图像 Prompt 的结构化公式

1.1 核心公式

一个高质量的图像 prompt 遵循以下六要素结构:

[主体] + [细节描述] + [风格/媒介] + [光照/氛围] + [构图/镜头] + [质量修饰符]
要素说明示例
主体(Subject)图像的核心对象”a golden retriever puppy”
细节描述(Details)动作、表情、服装、环境”sitting on a wooden dock, looking at the camera”
风格/媒介(Style)艺术风格或渲染方式”watercolor painting”, “photorealistic”, “3D render”
光照/氛围(Lighting)光线类型和情绪”golden hour, warm tones, soft shadows”
构图/镜头(Composition)视角、景别、景深”close-up portrait, shallow depth of field, 85mm lens”
质量修饰符(Quality)分辨率和细节级别”8K, ultra detailed, sharp focus”

1.2 各平台 Prompt 语法差异

特性Midjourney v7FLUX.2GPT-image-1Stable Diffusion 3.5Ideogram 3.0
Prompt 风格关键词堆叠 + 参数自然语言描述自然语言对话关键词 + 权重语法自然语言 + Magic Prompt
负面 Prompt--no 参数API negative_prompt 字段自然语言描述排除项独立负面 prompt 输入框内置过滤
宽高比--ar 16:9API width/height 参数size 参数(预设尺寸)自由设置宽高预设比例选择
风格控制--style raw / --stylize纯 prompt 描述纯 prompt 描述LoRA / ControlNetStyle Reference
种子控制--seed 12345API seed 参数不支持seed 参数不支持
权重语法::2 双冒号权重不支持不支持(keyword:1.5) 括号权重不支持

1.3 Prompt 长度建议

平台推荐长度说明
Midjourney v730-75 词过长会被截断,关键信息放前面
FLUX.250-150 词支持较长描述,细节越多越好
GPT-image-150-200 词自然语言理解强,可以写完整句子
Stable Diffusion 3.520-77 tokensCLIP 编码器限制,超出部分被忽略
Ideogram 3.030-100 词Magic Prompt 会自动扩展

2. 六大核心 Prompt 技巧

2.1 技巧一:“描述如何,而非什么”

这是图像 prompt 工程最重要的原则。不要只告诉 AI “画什么”,要告诉它”怎么画”。

❌ 差的 Prompt

一只猫

✅ 好的 Prompt

一只橘色虎斑猫蜷缩在窗台上,午后阳光透过薄纱窗帘洒在它身上, 形成温暖的光斑,猫咪半眯着眼睛,毛发在逆光中呈现金色边缘, 柔和的散景背景中隐约可见绿色植物, 写实摄影风格,85mm f/1.4 镜头,浅景深

关键区别

维度”什么”(差)“如何”(好)
主体”一个女人""一位 30 岁亚洲女性,短发,自信的微笑”
环境”在城市""站在雨后的东京涩谷十字路口,地面反射霓虹灯光”
光照(未指定)“蓝色时刻(blue hour),霓虹灯混合自然暮光”
情绪(未指定)“宁静而充满希望的氛围”
技术(未指定)“35mm 街拍风格,轻微颗粒感,电影色调”

2.2 技巧二:风格修饰符(Style Modifiers)

风格修饰符是控制图像整体视觉风格的关键词。以下是按类别整理的常用修饰符:

艺术媒介

修饰符效果适用场景
photorealistic照片级真实感产品图、人像、建筑
oil painting油画质感艺术创作、装饰画
watercolor水彩画风格插画、儿童读物
digital art数字艺术概念设计、游戏美术
3D render3D 渲染效果产品展示、建筑可视化
pencil sketch铅笔素描草图、手绘风格
anime / manga日式动漫风格角色设计、漫画
pixel art像素艺术游戏资产、复古风格
vector illustration矢量插画图标、信息图
isometric等距视角游戏场景、技术图解

摄影风格

修饰符效果
cinematic电影感,宽画幅,戏剧性光影
editorial photography杂志编辑风格,时尚感
street photography街拍风格,真实感,抓拍感
macro photography微距摄影,极致细节
aerial photography航拍视角
long exposure长曝光,光轨效果
tilt-shift移轴摄影,微缩模型感
double exposure双重曝光,艺术叠加

艺术运动/时代

修饰符效果
Art Nouveau新艺术运动,有机曲线
Art Deco装饰艺术,几何图案
Bauhaus包豪斯,简约功能主义
Cyberpunk赛博朋克,霓虹+暗色调
Steampunk蒸汽朋克,维多利亚+机械
Vaporwave蒸汽波,粉紫色调+复古
Studio Ghibli style吉卜力风格,温暖手绘
Ukiyo-e浮世绘,日本传统版画

2.3 技巧三:负面 Prompt(Negative Prompts)

负面 prompt 告诉 AI “不要生成什么”,是提升图像质量的关键手段。不同平台的负面 prompt 机制不同:

各平台负面 Prompt 用法

平台语法示例
Midjourney v7--no 参数--no text, watermark, blurry
FLUX.2API negative_prompt 字段"negative_prompt": "blurry, low quality"
GPT-image-1在正面 prompt 中用自然语言排除”…不要包含文字水印,避免模糊”
Stable Diffusion 3.5独立的负面 prompt 输入框bad anatomy, extra fingers, blurry
Ideogram 3.0内置 Magic Prompt 自动过滤通常无需手动设置

通用负面 Prompt 模板

按场景分类的常用负面 prompt 关键词:

质量类(几乎所有场景都应包含)

low quality, blurry, pixelated, jpeg artifacts, noise, grainy, overexposed, underexposed, out of focus

人物类(生成人像时必加)

bad anatomy, extra fingers, fused fingers, extra limbs, missing fingers, deformed hands, distorted face, cross-eyed, asymmetric eyes, unnatural pose

构图类

cropped, cut off, bad framing, tilted horizon, cluttered background, distracting elements

风格类(追求真实感时使用)

cartoon, anime, illustration, painting, sketch, artificial, plastic, CGI look, uncanny valley

水印/文字类

watermark, text, logo, signature, copyright, username, banner, stamp

负面 Prompt 最佳实践

  1. 少即是多:不要堆砌过多负面关键词,5-15 个即可,过多可能导致图像质量下降
  2. 针对性使用:根据实际生成结果中出现的问题添加,而非盲目复制通用模板
  3. 权重控制(Stable Diffusion):对特别重要的排除项加权,如 (extra fingers:1.5)
  4. 迭代优化:先生成一版,观察问题,再针对性添加负面 prompt

2.4 技巧四:宽高比控制(Aspect Ratio)

宽高比直接决定图像的用途和视觉效果。选择正确的宽高比是 prompt 工程的基础。

常用宽高比速查表

宽高比尺寸示例适用场景平台参数
1:11024×1024Instagram 帖子、头像、图标MJ: --ar 1:1
4:31024×768传统照片、演示文稿MJ: --ar 4:3
3:21024×683经典摄影比例、打印照片MJ: --ar 3:2
16:91920×1080YouTube 缩略图、博客封面、桌面壁纸MJ: --ar 16:9
9:161080×1920Instagram Stories、TikTok、手机壁纸MJ: --ar 9:16
21:92560×1080电影宽银幕、网站 Hero BannerMJ: --ar 21:9
2:3683×1024Pinterest Pin、海报、书籍封面MJ: --ar 2:3
3:4768×1024竖版海报、手机端展示MJ: --ar 3:4

场景选型建议

社交媒体帖子(Instagram/微博) → 1:1 或 4:5 社交媒体故事(Stories/Reels) → 9:16 博客/文章封面 → 16:9 YouTube 缩略图 → 16:9 产品详情页 → 1:1 或 4:3 海报/传单 → 2:3 或 3:4 网站 Hero Banner → 21:9 或 16:9 电商产品主图 → 1:1 手机壁纸 → 9:16 桌面壁纸 → 16:9 或 21:9

2.5 技巧五:构图与光照

构图关键词

类别关键词效果
景别extreme close-up极特写,聚焦细节(眼睛、纹理)
close-up特写,头肩部
medium shot中景,腰部以上
full body shot全身照
wide shot / establishing shot远景,展示环境
视角eye level平视,最自然
low angle / worm's eye view仰视,显得高大威严
high angle / bird's eye view俯视,显得渺小
overhead / top-down / flat lay正上方俯拍,适合产品摆拍
Dutch angle / tilted倾斜构图,不安感
构图法则rule of thirds三分法构图
centered composition居中对称构图
leading lines引导线构图
negative space大面积留白
symmetrical对称构图
golden ratio黄金比例构图

光照关键词

类别关键词效果
自然光golden hour日出/日落黄金时刻,温暖柔和
blue hour日出前/日落后蓝色时刻,冷调
overcast / diffused light阴天散射光,均匀柔和
harsh midday sun正午强光,硬阴影
dappled light树荫斑驳光影
人工光studio lighting影棚灯光,专业感
softbox lighting柔光箱,柔和均匀
ring light环形灯,眼神光明显
neon lighting霓虹灯,赛博朋克感
candlelight烛光,温馨浪漫
光照技法rim lighting / backlight轮廓光/逆光,勾勒边缘
Rembrandt lighting伦勃朗光,经典人像三角光
chiaroscuro明暗对比法,戏剧性
high key高调,明亮清新
low key低调,暗沉神秘
volumetric lighting体积光,光束可见

2.6 技巧六:镜头语言

模拟真实摄影镜头参数可以显著提升图像的专业感:

镜头参数效果适用场景
shot on 24mm lens广角,空间感强,轻微畸变风景、建筑、环境人像
shot on 35mm lens自然视角,环境+人物平衡街拍、纪实、环境肖像
shot on 50mm lens标准视角,最接近人眼通用摄影、日常记录
shot on 85mm lens人像黄金焦段,柔美虚化人像、特写
shot on 135mm lens长焦压缩,强烈虚化人像特写、运动
shot on 200mm lens超长焦,极致压缩感野生动物、体育
f/1.4shallow depth of field大光圈,背景虚化强人像、产品特写
f/8deep depth of field小光圈,全景清晰风景、建筑、集体照
tilt-shift lens移轴效果,微缩模型感城市俯瞰、创意摄影
fisheye lens鱼眼,极端广角畸变创意摄影、极限运动

工具推荐:Prompt 辅助工具

工具用途价格适用场景
PromptHero Prompt 搜索引擎,浏览他人作品和 prompt免费 / Pro $9/月寻找灵感、学习优秀 prompt
Lexica Stable Diffusion prompt 搜索免费SD 用户查找参考 prompt
Arthub.ai AI 艺术社区,prompt 分享免费跨平台 prompt 参考
PromptPerfect AI prompt 优化器免费试用 / $9.99/月自动优化和扩展 prompt
Midjourney Prompt Helper 可视化 prompt 构建器免费Midjourney 用户快速构建 prompt
fal.ai Prompt Generator FLUX 模型 prompt 生成免费FLUX 用户优化 prompt

3. 十大场景 Prompt 模板库

以下模板使用 [占位符] 标记可替换部分,适用于所有主流图像生成平台。

模板 1:产品摄影(Product Photography)

Professional product photography of [产品名称], placed on [表面: polished marble / rustic wood / gradient seamless], [背景: minimalist white / soft gradient / lifestyle setting with props], [光照: softbox key light with subtle rim light / natural window light], [视角: hero shot at 45 degrees / flat lay top-down / three-quarter view], commercial quality, sharp focus, subtle reflection on surface, [额外: with packaging / floating in air / exploded view showing components] --ar [1:1 产品主图 / 4:3 详情页 / 16:9 Banner]

示例

Professional product photography of a matte black wireless headphone, placed on polished dark marble surface, minimalist dark gradient background with subtle blue accent light, softbox key light from upper left with rim light highlighting edges, hero shot at 45 degrees, shallow depth of field, commercial quality, sharp focus, subtle reflection on surface --ar 1:1

模板 2:人像摄影(Portrait Photography)

[景别: Close-up portrait / Half-body / Full-body] of a [年龄] [性别] [外貌特征], [表情/情绪: confident smile / contemplative gaze / laughing naturally], wearing [服装描述], in [环境: urban rooftop at sunset / cozy café / lush garden], [光照: golden hour warm light / Rembrandt lighting / soft diffused overcast], shot on [镜头: 85mm f/1.4 / 50mm f/1.8], shallow depth of field, [风格: editorial fashion / candid street / cinematic portrait], skin texture visible, natural color grading --ar [2:3 竖版 / 3:2 横版 / 1:1 头像]

示例

Close-up portrait of a 25-year-old woman with short black hair, confident smile with warm eyes, wearing a cream linen blazer over a white t-shirt, in a sunlit café with plants in the background, golden hour warm light streaming through large windows, shot on 85mm f/1.4, shallow depth of field, editorial fashion style, skin texture visible, natural color grading --ar 2:3

模板 3:风景摄影(Landscape Photography)

[场景类型: Majestic mountain landscape / Serene coastal scene / Dense forest path] of [具体地点或描述], [时间: during golden hour / at blue hour / under starry night sky / misty morning], [天气: clear sky with dramatic clouds / fog rolling through valleys / after rain], [前景元素: wildflowers / rocky shore / winding path], [光照: warm side lighting / dramatic god rays / soft diffused light], shot on [24mm wide angle / 35mm / 16mm ultra-wide], deep depth of field, [风格: National Geographic / fine art landscape / moody atmospheric], vivid colors, high dynamic range --ar [16:9 宽幅 / 21:9 超宽 / 3:2 经典]

示例

Majestic mountain landscape of snow-capped peaks reflected in a crystal-clear alpine lake, during golden hour with warm orange and pink sky, dramatic clouds catching the last light, wildflowers and smooth rocks in the foreground, warm side lighting creating long shadows, shot on 24mm wide angle, deep depth of field, National Geographic style, vivid colors, high dynamic range --ar 16:9

模板 4:UI/UX 设计原型(UI Mockup)

Clean modern UI design for a [应用类型: mobile app / web dashboard / SaaS platform], [页面: login screen / dashboard / settings page / onboarding flow], [设计风格: minimalist / glassmorphism / neomorphism / material design], [配色: dark mode with blue accents / light mode with warm tones / monochrome], [布局: card-based layout / sidebar navigation / tab-based], featuring [功能元素: data charts / user profile / notification center], clean typography, consistent spacing, [设备: iPhone 16 mockup / MacBook screen / iPad], Figma/Dribbble quality, UI/UX design showcase --ar [9:16 手机 / 16:9 桌面 / 4:3 平板]

示例

Clean modern UI design for a fitness tracking mobile app, dashboard screen showing daily activity summary, minimalist design with glassmorphism cards, dark mode with vibrant green and blue accent colors, card-based layout with bottom navigation bar, featuring step counter ring, heart rate chart, and workout history, clean typography, consistent spacing, iPhone 16 mockup, Dribbble quality, UI/UX design showcase --ar 9:16

模板 5:图标设计(Icon Design)

[图标风格: Flat / 3D rendered / Line art / Glassmorphism / Clay] icon of [图标主题], [形状: rounded square / circle / hexagon] background in [颜色], [细节: subtle gradient / long shadow / inner glow], [用途: app icon / web icon set / emoji style], clean vector style, centered composition, [背景: transparent / solid color / gradient], high contrast, pixel-perfect, scalable design --ar 1:1

示例

3D rendered clay-style icon of a rocket ship launching, rounded square background with soft blue-to-purple gradient, subtle shadow beneath the rocket, playful and modern, app icon style, centered composition, clean and minimal, high contrast, pixel-perfect --ar 1:1

模板 6:社交媒体图形(Social Media Graphics)

Eye-catching social media [类型: post / story / carousel cover / banner] for [主题/品牌], [内容: announcing a product launch / sharing a quote / promoting an event], [文字(Ideogram/GPT-image-1 推荐): "标题文字" in bold modern font], [配色: brand colors [色值] / trending gradient / high contrast], [风格: modern minimalist / bold and colorful / elegant and sophisticated], [元素: abstract shapes / product photo integration / pattern background], engaging composition, scroll-stopping design --ar [1:1 帖子 / 9:16 故事 / 16:9 封面]

示例

Eye-catching social media post for a tech startup product launch, announcing "AI Assistant 2.0 is Here" in bold modern sans-serif font, dark navy background with electric blue and cyan gradient accents, modern minimalist style with abstract geometric shapes, product screenshot floating with subtle shadow, engaging composition, scroll-stopping design --ar 1:1

模板 7:品牌视觉(Brand Visual)

[品牌资产类型: Brand identity mockup / Business card / Letterhead / Packaging], for a [行业: tech startup / luxury fashion / organic food / fitness] brand, brand name "[品牌名]" in [字体风格: modern sans-serif / elegant serif / handwritten], [配色方案: [主色] and [辅色] color palette], [风格: premium and sophisticated / playful and energetic / clean and professional], [材质: matte paper / metallic foil / kraft paper / glossy], [展示方式: flat lay arrangement / perspective mockup / floating elements], professional graphic design, print-ready quality --ar [1:1 / 4:3 / 16:9]

示例

Brand identity mockup for a premium coffee brand, brand name "BREW & CO" in elegant modern serif font, deep brown and warm gold color palette with cream accents, premium and sophisticated style, showing business card, coffee cup, and packaging bag, kraft paper texture with gold foil stamping details, flat lay arrangement on dark wood surface, professional graphic design, print-ready quality --ar 4:3

模板 8:概念艺术(Concept Art)

[概念类型: Character concept art / Environment concept / Creature design / Vehicle design] for a [类型: sci-fi / fantasy / post-apocalyptic / cyberpunk] [媒体: game / film / novel], [主体描述: 详细的角色/环境/生物描述], [氛围: epic and grandiose / dark and mysterious / whimsical and colorful], [光照: dramatic volumetric lighting / bioluminescent glow / harsh industrial], [视角: dynamic action pose / turnaround sheet / establishing wide shot], [风格: digital painting / matte painting / concept art illustration], highly detailed, professional concept art quality, [参考艺术家风格(可选): in the style of Feng Zhu / Craig Mullins / Syd Mead] --ar [16:9 环境 / 2:3 角色 / 1:1 生物]

示例

Environment concept art for a cyberpunk megacity, massive neon-lit skyscrapers towering above foggy lower streets, flying vehicles weaving between buildings, holographic advertisements reflecting on wet pavement, dark and atmospheric with vibrant neon accents in pink and cyan, dramatic volumetric lighting with god rays through smog, establishing wide shot from street level looking up, digital matte painting style, highly detailed, cinematic --ar 21:9

模板 9:建筑可视化(Architectural Visualization)

[建筑类型: Modern residential house / Commercial office building / Interior design] [描述: 具体建筑特征], [环境: surrounded by landscaped garden / urban setting / waterfront], [时间: golden hour exterior / bright daylight / twilight with interior lights on], [风格: photorealistic architectural render / minimalist / warm Scandinavian], [材质: glass and steel / exposed concrete / natural wood and stone], [视角: exterior front elevation / aerial perspective / interior wide angle], architectural photography style, clean lines, professional 3D visualization quality, V-Ray / Unreal Engine render look --ar [16:9 外观 / 4:3 室内 / 1:1 细节]

示例

Modern minimalist residential house with floor-to-ceiling glass walls, white concrete structure with warm wood accents and a green roof, surrounded by a Japanese-inspired zen garden with a reflecting pool, twilight scene with warm interior lights glowing through glass, photorealistic architectural render, clean geometric lines, exterior front elevation at eye level, professional 3D visualization quality, V-Ray render look --ar 16:9

模板 10:美食摄影(Food Photography)

[美食类型: Gourmet dish / Street food / Dessert / Beverage] photography of [菜品名称], [摆盘: artfully plated on [餐具] / rustic presentation / deconstructed], [配菜/装饰: garnished with fresh herbs / sauce drizzle / scattered ingredients], [表面: marble countertop / rustic wooden table / dark slate], [光照: soft natural window light from left / moody dark and dramatic / bright and airy], [视角: overhead flat lay / 45-degree hero angle / close-up detail], [风格: editorial food photography / cozy homestyle / fine dining], appetizing colors, steam/condensation visible, shallow depth of field --ar [1:1 社交媒体 / 4:3 菜单 / 16:9 Banner]

示例

Gourmet dessert photography of a chocolate lava cake with molten center flowing out, artfully plated on a matte black ceramic plate, garnished with fresh raspberries, mint leaf, and gold dust, dark slate surface with scattered cocoa powder, moody dramatic lighting with a single soft light from upper right, 45-degree hero angle, shallow depth of field, fine dining editorial food photography style, rich warm tones, steam rising, appetizing and luxurious --ar 1:1

附加模板:快速参考卡片

#场景Prompt 骨架推荐平台推荐宽高比
1产品摄影Product photography of [产品], [表面], [光照], [视角]FLUX.2 / GPT-image-11:1
2人像[景别] portrait of [人物], [表情], [环境], [镜头]Midjourney / FLUX.22:3
3风景[场景] landscape, [时间], [天气], [前景], [镜头]Midjourney / FLUX.216:9
4UI 原型UI design for [应用], [页面], [风格], [配色], [设备]GPT-image-1 / Ideogram9:16
5图标[风格] icon of [主题], [形状], [颜色], centeredMidjourney / Leonardo1:1
6社交媒体Social media [类型] for [主题], [文字], [配色]Ideogram / GPT-image-11:1 / 9:16
7品牌视觉Brand [资产] for [行业], "[品牌名]", [配色], [材质]Ideogram / Midjourney4:3
8概念艺术[类型] concept art for [世界观], [描述], [氛围]Midjourney / Leonardo16:9
9建筑可视化[建筑类型], [材质], [环境], [时间], architectural renderFLUX.2 / Midjourney16:9
10美食摄影[美食类型] photography of [菜品], [摆盘], [光照]FLUX.2 / GPT-image-11:1

实战案例:为电商品牌构建一致性产品图 Prompt 体系

背景

一个 DTC(Direct-to-Consumer)护肤品牌需要为 30 款产品生成统一风格的电商主图和详情页图片。要求:

  • 所有产品图风格高度一致(品牌色:米白 + 淡金)
  • 每款产品需要 4 张图:主图(1:1)、详情页横图(16:9)、成分展示(4:3)、使用场景(2:3)
  • 总计 120 张图,预算 $50 以内

步骤 1:建立品牌 Prompt 基础模板

# 品牌 Prompt 基础层(所有图片共享) BRAND_BASE = """ Premium skincare product photography, color palette: warm ivory (#FFFFF0), soft gold (#D4AF37), and sage green (#9CAF88), clean minimalist aesthetic, soft natural lighting, high-end luxury feel, commercial quality, sharp focus """

步骤 2:定义四种图片类型的 Prompt 变体

# 主图模板(1:1) HERO_TEMPLATE = f""" {BRAND_BASE} Product hero shot of [产品名称] bottle/jar, centered on a smooth ivory marble surface, soft gradient background from warm white to pale gold, single softbox light from upper left creating gentle shadow, product label clearly visible, subtle reflection on surface """ # 详情页横图模板(16:9) DETAIL_TEMPLATE = f""" {BRAND_BASE} Lifestyle product shot of [产品名称], placed among natural ingredients: [相关成分如 fresh lavender, honey, aloe], on a light wooden surface with linen cloth, soft diffused window light, airy and bright atmosphere, ingredients artfully scattered around the product """ # 成分展示模板(4:3) INGREDIENT_TEMPLATE = f""" {BRAND_BASE} Flat lay overhead shot of [产品名称] surrounded by its key ingredients, [成分1], [成分2], [成分3] arranged in an aesthetic pattern, on a clean white surface with subtle shadows, botanical and fresh feeling, ingredient-focused composition """ # 使用场景模板(2:3) LIFESTYLE_TEMPLATE = f""" {BRAND_BASE} Lifestyle scene of a woman applying [产品名称] in a bright bathroom, soft morning light through frosted glass window, clean modern bathroom with plants and natural elements, warm and inviting atmosphere, self-care moment, product visible but scene-focused, editorial style """

步骤 3:批量生成脚本

import openai client = openai.OpenAI() products = [ {"name": "Hydrating Serum", "ingredients": "hyaluronic acid drops, rose petals, cucumber slices"}, {"name": "Night Cream", "ingredients": "lavender sprigs, shea butter chunks, chamomile flowers"}, # ... 更多产品 ] SIZES = { "hero": "1024x1024", # 1:1 "detail": "1792x1024", # 16:9 "ingredient": "1024x768", # 4:3(近似) "lifestyle": "1024x1792", # 9:16 → 裁剪为 2:3 } for product in products: for img_type, size in SIZES.items(): prompt = TEMPLATES[img_type].replace("[产品名称]", product["name"]) if "[相关成分" in prompt or "[成分" in prompt: prompt = prompt.replace("[相关成分如 fresh lavender, honey, aloe]", product["ingredients"]) response = client.images.generate( model="gpt-image-1", prompt=prompt, size=size, quality="medium", # 中质量平衡成本 n=1 ) print(f"✅ {product['name']} - {img_type}: {response.data[0].url}")

案例分析

  • 成本计算:30 产品 × 4 张 × ~$0.07/张(中质量)= ~$8.40,远低于 $50 预算
  • 一致性保障:通过共享 BRAND_BASE 模板确保所有图片的色调、风格、质感统一
  • 关键决策:选择 GPT-image-1 而非 FLUX.2,因为产品标签上的文字需要清晰渲染
  • 优化空间:可使用 Batch API 异步处理,成本再降 50%(~$4.20 完成全部 120 张)
  • 迭代策略:先为 1 款产品生成 4 张测试,确认风格满意后再批量执行

避坑指南

❌ 常见错误

  1. Prompt 过于模糊,缺少具体描述

    • 问题:写”一个漂亮的风景”,AI 不知道你想要什么风格、什么时间、什么构图
    • 正确做法:使用六要素公式(主体+细节+风格+光照+构图+质量),每个维度都给出具体描述
  2. 堆砌矛盾的关键词

    • 问题:同时写”photorealistic”和”anime style”,或”bright sunny”和”dark moody”,AI 会困惑
    • 正确做法:确保所有关键词在风格、光照、氛围上保持一致;如果不确定,先用简单 prompt 测试
  3. 忽略宽高比导致构图失败

    • 问题:用 1:1 比例生成全身人像,结果头部被裁切或人物过小
    • 正确做法:全身人像用 2:3 或 9:16 竖版;风景用 16:9 或 21:9 横版;产品主图用 1:1
  4. 负面 Prompt 过度使用

    • 问题:复制粘贴 50+ 个负面关键词,反而导致图像质量下降或出现奇怪的伪影
    • 正确做法:只添加 5-15 个针对性的负面关键词,根据实际生成结果中的问题逐步添加
  5. 在不支持的平台使用权重语法

    • 问题:在 GPT-image-1 或 FLUX.2 中使用 (keyword:1.5)::2 语法,这些平台不识别
    • 正确做法:了解各平台的语法差异(见 1.2 节对比表),用自然语言强调重要元素
  6. 忽视 Prompt 中关键词的顺序

    • 问题:把最重要的描述放在 prompt 末尾,被模型忽略(尤其是 Stable Diffusion 的 77 token 限制)
    • 正确做法:最重要的元素放在 prompt 开头,次要细节放后面

✅ 最佳实践

  1. 建立个人 Prompt 模板库:为常用场景保存经过验证的模板,每次只替换变量部分,确保输出一致性
  2. 单变量迭代法:每次只修改 prompt 中的一个元素(如只改光照),对比效果,逐步优化到满意
  3. 善用种子值(Seed):在 Midjourney 和 Stable Diffusion 中固定 seed,确保修改 prompt 时只有目标变量变化
  4. 先粗后细:先用简短 prompt 确定大方向,再逐步添加细节描述精修
  5. 跨平台测试:同一个 prompt 在不同平台生成效果差异很大,重要项目建议在 2-3 个平台测试后选择最佳结果

相关资源与延伸阅读

  1. Image Prompts: The Definitive Visual Synthesis Guide  — 全面的图像 prompt 结构化指南,覆盖各平台最佳实践
  2. Stable Diffusion Prompt Guide  — Stable Diffusion 官方社区的 prompt 编写权威指南
  3. Midjourney Documentation — Prompts  — Midjourney 官方 prompt 语法和参数文档
  4. OpenAI Image Generation Guide  — GPT-image-1 和 DALL-E 的官方 prompt 指南
  5. PromptHero  — 最大的 AI 图像 prompt 搜索引擎,可按平台和风格筛选
  6. Lexica.art  — Stable Diffusion 作品和 prompt 搜索引擎
  7. Civitai Prompt Guide  — Civitai 社区的 prompt 编写教程电子书
  8. AI Image Prompts: 50+ Templates (2026)  — 按场景分类的 50+ prompt 模板集合
  9. Nano Banana Prompt Engineering Best Practices  — Gemini 图像生成的 prompt 工程最佳实践
  10. 120+ Stable Diffusion Negative Prompts Guide  — 负面 prompt 完整参考指南

参考来源

信息截止日期:2025 年 8 月。图像 prompt 技巧随模型更新持续演进,建议关注各平台官方文档获取最新语法和参数变化。


📖 返回 总览与导航 | 上一节:13a-图像生成工具对比 | 下一节:13c-API集成编程生成

Last updated on