🎨使用 GPT-4o 和 GPT-Image-1 进行受控图像生成的 JSON 风格指南
使用 GPT-4o 和 GPT-Image-1 生成图像可以产生令人惊艳的视觉效果,但如果没有清晰的指令,结果可能会有所不同。使用JSON 样式指南是使提示信息清晰、结构化且可重复的有效方法。本教程将带您了解 JSON 样式指南的重要性、如何有效地使用它们,并提供您可以定义的所有参数的完整参考。
🚀 为什么要使用 JSON 风格指南?
自然语言功能强大,但常常含糊不清。通过使用 JSON 组织图像提示:
- ✅使用结构化字段可以消除歧义。
- ✅ 您确保了多代人的一致性。
- ✅ 您可以自动创建提示信息或进行批量处理。
- ✅ 将内容与样式分开,使迭代更容易。
- ✅ 开发人员和设计师可以使用共享的、机器可读的格式协同工作。
🛠️ 如何使用 JSON 样式指南
JSON 提示符其实就是一个结构化的文档,用于指定模型需要包含的所有内容。以下是一个简单的示例:
{
"scene": "a magical forest clearing",
"subjects": [
{
"type": "fox",
"description": "wearing a wizard hat, sitting on a tree stump",
"position": "center"
}
],
"style": "storybook illustration",
"color_palette": ["forest green", "gold", "midnight blue"],
"lighting": "soft dappled sunlight",
"mood": "whimsical and cozy",
"background": "glowing mushrooms and tall trees",
"composition": "eye-level view, centered subject"
}
这种结构为模型提供了明确的、可解释的指令,用于指示要渲染什么以及如何渲染。
📚 参数参考
以下是 JSON 风格指南中可以使用的字段列表。
1.scene
对整个场景或环境的简要概述。
- 例子:
"a futuristic city at sunset"
2. subjects (对象数组)
描述图像中的每个主要对象。每个对象可以包括:
{
"type": "robot",
"description": "silver body with glowing blue eyes",
"position": "foreground",
"pose": "standing upright",
"size": "large",
"expression": "neutral",
"interaction": "looking at a floating screen"
}
3.style
艺术或视觉表现风格。
- 例如:
"photorealistic",,,,"watercolor""pixel art""cyberpunk""anime"
4.color_palette
一系列主色和点缀色。
- 例子:
["emerald green", "burnt orange", "charcoal"]
5.lighting
图像的布光方式。
- 例如:
"sunset backlight",,"soft studio lighting""glow from below"
6.mood
情感基调或氛围。
- 例如:
"peaceful",,,"dramatic""eerie""playful"
7.background
风景或背景。
- 例如:
"mountain landscape",,"white cyclorama""dreamy nebula sky"
8.composition
整体布局和定位。
- 例如:
"symmetrical",,,"rule of thirds""top-down shot""portrait orientation"
9.camera
虚拟摄影设置。
{
"angle": "eye-level",
"distance": "medium shot",
"lens": "wide-angle",
"focus": "sharp subject, blurred background"
}
10.medium
模拟介质或格式。
- 例如:
"oil painting",,,"3D render""ink drawing""chalkboard sketch"
11.textures
表面质感和触感。
- 例如:
"soft velvet",,"rusty metal""wet pavement"
12.resolution
预期分辨率或输出尺寸。
- 例如:
"4K",,"web banner""Instagram square"
13.details
额外精细化的属性。
{
"clothing": "flowing red cape",
"weather": "light snowfall",
"facial_features": "freckles and sharp jawline",
"material": "glass and brass",
"ornaments": "glasses, ring"
}
14.effects
特效或视觉处理。
- 例如:
"lens flare",,,"bokeh blur""double exposure""film grain"
15.inspirations
已知的参考资料可指导视觉风格。
- 例如:
"inspired by Studio Ghibli",,"in the style of Van Gogh""similar to Blade Runner"
🧪 用例示例
奇幻角色概念艺术
{
"scene": "mountaintop at sunrise",
"subjects": [
{
"type": "warrior elf",
"description": "leather armor, long silver hair",
"pose": "standing with sword raised",
"position": "foreground"
}
],
"style": "digital painting",
"color_palette": ["misty gray", "light gold", "teal"],
"lighting": "sunrise backlight",
"mood": "heroic and calm",
"background": "foggy mountains",
"composition": "rule of thirds",
"camera": {
"angle": "low angle",
"distance": "medium shot",
"focus": "sharp on character"
}
}
产品模型
{
"scene": "minimalist white studio",
"subjects": [
{
"type": "smartwatch",
"description": "silver frame with red strap",
"position": "center",
"pose": "lying flat"
}
],
"style": "photorealistic",
"lighting": "diffused light from above",
"mood": "clean and sleek",
"background": "white gradient",
"composition": "centered product with top view",
"resolution": "4K"
}
包含两个角色的逼真场景
{
"scene": "urban café terrace in Paris during golden hour",
"subjects": [
{
"type": "young woman",
"description": "30s, Black hair in a bun, wearing a white blouse and tan trench coat, holding a coffee cup",
"pose": "sitting at a café table, leaning forward slightly",
"position": "left foreground",
"expression": "engaged, smiling softly"
},
{
"type": "young man",
"description": "30s, light brown curly hair, wearing a navy blue jacket and scarf, gesturing with one hand",
"pose": "sitting across from the woman, mid-conversation",
"position": "right foreground",
"expression": "animated, talking"
}
],
"style": "hyper-realistic photography",
"lighting": "natural golden hour light with soft shadows and sun flare",
"mood": "warm and intimate",
"background": {
"elements": ["street with bicycles", "café signage", "distant pedestrians"],
"depth_of_field": "shallow, blurred background"
},
"composition": "framed using the rule of thirds, both characters centered with table between them",
"camera": {
"angle": "eye level",
"distance": "medium close-up",
"focus": "sharp on characters' faces"
},
"color_palette": ["warm gold", "beige", "navy", "soft rose", "espresso brown"],
"props": ["ceramic coffee cups", "croissants on a small plate", "notebook and pen on table"],
"resolution": "4K"
}
使用 JSON 样式指南,您可以获得一致、模块化且精确的图像生成控制方式。无论您是创建角色作品集、设计品牌资产还是构建环境原型,结构化的提示都能让您清晰地沟通,并自信地扩展项目规模。
别犹豫,使用 ChatGPT 来完善或共同创建您的 JSON 样式指南!它可以在几秒钟内将模糊的想法转化为结构化的、可直接生成的提示。
文章来源:https://dev.to/worldlinetech/json-style-guides-for-driven-image- Generation-with-gpt-4o-and-gpt-image-1-36p



