|
1
|
--- |
|
2
|
name: media-generation |
|
3
|
description: "Generate and retrieve media including AI-generated images and stock images. Use this skill for visual content creation and retrieval. For AI video clips, read `media-generation/video_generation.md`; for music, sound effects, and text-to-speech audio, read `media-generation/audio_generation.md`" |
|
4
|
--- |
|
5
|
|
|
6
|
# Media Generation Skill |
|
7
|
|
|
8
|
Generate custom images, and retrieve stock images. |
|
9
|
|
|
10
|
## Available Functions |
|
11
|
|
|
12
|
### generateImage(images, ...) |
|
13
|
|
|
14
|
Generate custom images from text descriptions. Waits for generation to complete before returning. |
|
15
|
|
|
16
|
**Parameters:** |
|
17
|
|
|
18
|
- `images` (list, **required**): A list of image request objects. **This wrapper is always required — even for a single image, pass `images: [{ ... }]`**. Up to 10 images can be generated in a single call. Each dict should have: |
|
19
|
- `prompt` (required): Text description of the desired image |
|
20
|
- `outputPath`: File path **must end in `.png`** — this is the only accepted format. `.jpg`, `.jpeg`, `.webp`, and other extensions will cause an error. Defaults to `attached_assets/generated_images/{summary}.png` |
|
21
|
- `aspectRatio`: Optional, defaults to "1:1". Options: "1:1", "3:4", "4:3", "9:16", "16:9" |
|
22
|
- `negativePrompt`: Optional, description of what should NOT appear |
|
23
|
- `summary`: Optional, short 4-5 word description for default filename |
|
24
|
- `removeBackground`: Optional, defaults to False |
|
25
|
- `overwrite` (bool, default True): Whether to overwrite existing files |
|
26
|
|
|
27
|
**Returns:** Dict with `images` list (each with `filePath` and `description`) and optional `failures` list |
|
28
|
|
|
29
|
**Common Mistakes:** |
|
30
|
|
|
31
|
```javascript |
|
32
|
// WRONG — flat params without images array (causes "images field required" error) |
|
33
|
await generateImage({ prompt: "A mountain landscape", outputPath: "hero.png" }); |
|
34
|
|
|
35
|
// CORRECT — always wrap in images: [...], even for a single image |
|
36
|
await generateImage({ images: [{ prompt: "A mountain landscape", outputPath: "hero.png" }] }); |
|
37
|
|
|
38
|
// WRONG — .jpg extension is not supported (causes "outputPath must end with .png" error) |
|
39
|
await generateImage({ images: [{ prompt: "A cityscape", outputPath: "city.jpg" }] }); |
|
40
|
|
|
41
|
// CORRECT — only .png is accepted |
|
42
|
await generateImage({ images: [{ prompt: "A cityscape", outputPath: "city.png" }] }); |
|
43
|
``` |
|
44
|
|
|
45
|
**Examples:** |
|
46
|
|
|
47
|
```javascript |
|
48
|
// Single image |
|
49
|
const result = await generateImage({ |
|
50
|
images: [ |
|
51
|
{ |
|
52
|
prompt: "A serene mountain landscape at sunset with snow-capped peaks", |
|
53
|
outputPath: "src/assets/images/hero.png", |
|
54
|
aspectRatio: "16:9", |
|
55
|
negativePrompt: "blurry, low quality", |
|
56
|
} |
|
57
|
] |
|
58
|
}); |
|
59
|
console.log(`Image saved to: ${result.images[0].filePath}`); |
|
60
|
|
|
61
|
// Multiple images at once |
|
62
|
const result = await generateImage({ |
|
63
|
images: [ |
|
64
|
{ prompt: "A red apple", outputPath: "assets/apple.png" }, |
|
65
|
{ prompt: "A yellow banana", outputPath: "assets/banana.png" }, |
|
66
|
{ prompt: "An orange", outputPath: "assets/orange.png", removeBackground: true }, |
|
67
|
] |
|
68
|
}); |
|
69
|
for (const img of result.images) { |
|
70
|
console.log(`Generated: ${img.filePath}`); |
|
71
|
} |
|
72
|
``` |
|
73
|
|
|
74
|
### generateImageAsync(images, ...) |
|
75
|
|
|
76
|
Generate images asynchronously. Returns immediately with a workflow ID. Same parameters as `generateImage`. |
|
77
|
|
|
78
|
**Returns:** Dict with `workflowId`, `workflowAlias`, `status`, and `imagePaths` |
|
79
|
|
|
80
|
**Example:** |
|
81
|
|
|
82
|
```javascript |
|
83
|
const result = await generateImageAsync({ |
|
84
|
images: [ |
|
85
|
{ prompt: "A complex detailed illustration", outputPath: "assets/illustration.png" }, |
|
86
|
] |
|
87
|
}); |
|
88
|
console.log(`Started workflow: ${result.workflowAlias}`); |
|
89
|
console.log(`Images will be saved to: ${result.imagePaths}`); |
|
90
|
``` |
|
91
|
|
|
92
|
### stockImage(description, ...) |
|
93
|
|
|
94
|
Retrieve stock images matching a description. |
|
95
|
|
|
96
|
**Parameters:** |
|
97
|
|
|
98
|
- `description` (str, required): Text description of desired stock image(s) |
|
99
|
- `summary` (str, default "stock_image"): Short description for the filename |
|
100
|
- `limit` (int, default 1): Number of images to retrieve (1-10) |
|
101
|
- `orientation` (str, default "horizontal"): "horizontal", "vertical", or "all" |
|
102
|
|
|
103
|
**Returns:** Dict with `filePaths` list and `query` string |
|
104
|
|
|
105
|
**Example:** |
|
106
|
|
|
107
|
```javascript |
|
108
|
const result = await stockImage({ |
|
109
|
description: "modern office with natural lighting", |
|
110
|
summary: "office background", |
|
111
|
limit: 3, |
|
112
|
orientation: "horizontal" |
|
113
|
}); |
|
114
|
for (const path of result.filePaths) { |
|
115
|
console.log(`Stock image saved to: ${path}`); |
|
116
|
} |
|
117
|
``` |
|
118
|
|
|
119
|
## When to Use Each Function |
|
120
|
|
|
121
|
### generateImage / generateImageAsync |
|
122
|
|
|
123
|
- Custom illustrations or graphics not available elsewhere |
|
124
|
- Specific visual concepts or designs |
|
125
|
- Placeholder images for development |
|
126
|
- Creative or artistic content |
|
127
|
- Use `generateImageAsync` when images are not needed immediately |
|
128
|
|
|
129
|
### stockImage |
|
130
|
|
|
131
|
- Professional photography |
|
132
|
- Real-world scenes and people |
|
133
|
- Business and corporate imagery |
|
134
|
- When authenticity is more important than customization |
|
135
|
|
|
136
|
## Aspect Ratio Guidelines |
|
137
|
|
|
138
|
### Images |
|
139
|
|
|
140
|
- **1:1** - Square, good for profile pictures, thumbnails, icons |
|
141
|
- **3:4** - Portrait, good for mobile screens, product images |
|
142
|
- **4:3** - Landscape, good for presentations, desktop displays |
|
143
|
- **9:16** - Vertical, good for mobile stories, tall banners |
|
144
|
- **16:9** - Widescreen, good for hero images, video thumbnails |
|
145
|
|
|
146
|
## Best Practices |
|
147
|
|
|
148
|
1. **Write detailed prompts**: Include style, mood, lighting, colors, and composition |
|
149
|
2. **Use negative prompts**: Exclude unwanted elements like "blurry", "watermark", "text" |
|
150
|
3. **Choose appropriate formats**: Match aspect ratio and media type to intended use |
|
151
|
4. **Consider stock for realism**: Use stock images when you need authentic photography |
|
152
|
5. **Do not over generate**: Only generate multiple images when the user explicitly asks. |
|
153
|
|
|
154
|
## Output Locations |
|
155
|
|
|
156
|
- Generated images: `attached_assets/generated_images/` |
|
157
|
- Stock images: `attached_assets/stock_images/` |
|
158
|
|
|
159
|
## Limitations |
|
160
|
|
|
161
|
- Stock image availability depends on the search query |
|
162
|
- Complex or highly specific prompts may not match exactly |
|
163
|
- Text in generated media is not reliably rendered |
|
164
|
|
|
165
|
## Copyright |
|
166
|
|
|
167
|
- Use this skill to create media assets instead of copying from websites |
|
168
|
- Generated images are created for your use |
|
169
|
- Stock images are licensed for use in your projects |
|
170
|
- Do not download or copy media files from external websites |