@djangocfg/imgai 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,187 @@
1
+ # @djangocfg/imgai
2
+
3
+ AI-powered image generation & management for Next.js projects.
4
+
5
+ ## Features
6
+
7
+ - 🎨 **AI Image Generation** - Generate images using OpenAI DALL-E 3 or Claude
8
+ - 🔍 **Image Scanner** - Automatically find and catalog all images in your project
9
+ - ⚡ **Config Sync** - Generate TypeScript config with all images for type-safe access
10
+ - 📦 **Batch Processing** - Generate multiple images with concurrent workers
11
+ - 🖼️ **Image Optimization** - Automatic resize and format conversion (WebP, AVIF)
12
+ - 🎯 **Beautiful CLI** - Interactive and command-line interfaces
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add @djangocfg/imgai
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### Interactive Mode
23
+
24
+ ```bash
25
+ npx imgai
26
+ ```
27
+
28
+ ### Generate Single Image
29
+
30
+ ```bash
31
+ npx imgai generate "A beautiful sunset over mountains" --filename sunset --category backgrounds
32
+ ```
33
+
34
+ ### Scan & Sync
35
+
36
+ ```bash
37
+ # Scan all images
38
+ npx imgai scan
39
+
40
+ # Generate images.ts config
41
+ npx imgai sync
42
+ ```
43
+
44
+ ### Batch Generate
45
+
46
+ Create a `prompts.json` file:
47
+
48
+ ```json
49
+ [
50
+ { "prompt": "Abstract blue waves", "filename": "waves" },
51
+ { "prompt": "Geometric patterns", "filename": "patterns" },
52
+ "Simple prompt without filename"
53
+ ]
54
+ ```
55
+
56
+ Then run:
57
+
58
+ ```bash
59
+ npx imgai batch prompts.json --category abstract --concurrency 2
60
+ ```
61
+
62
+ ## Programmatic Usage
63
+
64
+ ```typescript
65
+ import { createImageAI, generateImage, scanImages, syncImagesConfig } from '@djangocfg/imgai';
66
+
67
+ // Quick helpers
68
+ const result = await generateImage('A beautiful landscape', {
69
+ projectRoot: process.cwd(),
70
+ });
71
+
72
+ const images = await scanImages({
73
+ projectRoot: process.cwd(),
74
+ });
75
+
76
+ await syncImagesConfig({
77
+ projectRoot: process.cwd(),
78
+ });
79
+
80
+ // Full control
81
+ const { generator, scanner, configGenerator } = createImageAI({
82
+ projectRoot: process.cwd(),
83
+ provider: 'openai',
84
+ size: '1792x1024',
85
+ quality: 'hd',
86
+ resize: {
87
+ width: 800,
88
+ height: 600,
89
+ format: 'webp',
90
+ quality: 85,
91
+ },
92
+ });
93
+
94
+ // Generate with enhanced prompt
95
+ const enhanced = await generator.enhancePrompt('A tech company landing page hero');
96
+ const image = await generator.generate({
97
+ prompt: enhanced.prompt,
98
+ filename: enhanced.filename,
99
+ category: 'heroes',
100
+ });
101
+
102
+ // Batch generate
103
+ const batchResult = await generator.generateBatch({
104
+ items: [
105
+ { prompt: 'Image 1', category: 'batch' },
106
+ { prompt: 'Image 2', category: 'batch' },
107
+ ],
108
+ concurrency: 2,
109
+ onProgress: (current, total, result) => {
110
+ console.log(`${current}/${total}: ${result.success ? '✓' : '✗'}`);
111
+ },
112
+ });
113
+
114
+ // Scan images
115
+ const catalog = await scanner.buildCatalog();
116
+ console.log(`Found ${catalog.count} images`);
117
+
118
+ // Generate images.ts
119
+ await configGenerator.generate();
120
+ ```
121
+
122
+ ## Generated Config (images.ts)
123
+
124
+ After running `imgai sync`, you get a fully typed `images.ts`:
125
+
126
+ ```typescript
127
+ import { getImage, getImageUrl, getImagesByCategory, hasImage } from '@/core/images';
128
+
129
+ // Type-safe image access
130
+ const heroImage = getImage('hero-landing');
131
+ const heroUrl = getImageUrl('hero-landing');
132
+
133
+ // Get all images in category
134
+ const backgroundImages = getImagesByCategory('backgrounds');
135
+
136
+ // Check if image exists
137
+ if (hasImage('my-image')) {
138
+ // TypeScript knows it exists
139
+ }
140
+ ```
141
+
142
+ ## CLI Commands
143
+
144
+ ```
145
+ imgai [interactive] Start interactive mode (default)
146
+ imgai generate <prompt> Generate single image
147
+ imgai scan Scan and list all images
148
+ imgai sync Generate/update images.ts
149
+ imgai batch <file> Batch generate from JSON file
150
+ ```
151
+
152
+ ## Options
153
+
154
+ ### Generate Options
155
+
156
+ ```
157
+ -f, --filename <name> Output filename
158
+ -c, --category <name> Category/folder (default: general)
159
+ -r, --root <path> Project root directory
160
+ -o, --output <path> Output directory
161
+ --size <size> Image size (1024x1024, 1792x1024, 1024x1792)
162
+ --quality <quality> Image quality (standard, hd)
163
+ --style <style> Style prefix for prompts
164
+ --resize Enable resize
165
+ --width <pixels> Resize width
166
+ --height <pixels> Resize height
167
+ --format <format> Output format (webp, jpeg, png, avif)
168
+ ```
169
+
170
+ ### Scan Options
171
+
172
+ ```
173
+ -r, --root <path> Project root directory
174
+ -d, --dirs <dirs> Directories to scan (comma-separated)
175
+ --no-dimensions Skip reading image dimensions
176
+ ```
177
+
178
+ ## Environment Variables
179
+
180
+ ```bash
181
+ OPENAI_API_KEY=sk-... # Required for image generation
182
+ ANTHROPIC_API_KEY=sk-ant-... # Optional for prompt enhancement with Claude
183
+ ```
184
+
185
+ ## License
186
+
187
+ MIT