@michelabboud/visual-forge-mcp 0.5.5 → 0.6.0

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.
@@ -0,0 +1,370 @@
1
+ # Image Optimization Guide
2
+
3
+ Visual Forge MCP automatically optimizes generated images for web use while preserving originals for high-quality print or archival purposes.
4
+
5
+ ## Overview
6
+
7
+ When images are generated, Visual Forge:
8
+ 1. **Generates** the image in original quality (PNG format)
9
+ 2. **Saves original** to `original/` subdirectory (never touched again)
10
+ 3. **Optimizes** for web use (WebP format by default)
11
+ 4. **Uses optimized** version in documentation
12
+
13
+ ## Directory Structure
14
+
15
+ ```
16
+ generated-images/
17
+ ├── gemini/
18
+ │ ├── original/ # 🔒 Original files (full quality)
19
+ │ │ ├── diagram-001.png # 4.2 MB - Original PNG
20
+ │ │ └── chart-002.png # 3.8 MB - Original PNG
21
+ │ │
22
+ │ ├── diagram-001.webp # 1.2 MB - Web optimized (used in docs)
23
+ │ └── chart-002.webp # 1.0 MB - Web optimized (used in docs)
24
+ ```
25
+
26
+ ## Configuration
27
+
28
+ Control optimization via environment variables in your `.env` file:
29
+
30
+ ### Enable/Disable Optimization
31
+
32
+ ```bash
33
+ # Enable optimization (default: true)
34
+ IMAGE_OPTIMIZATION_ENABLED=true
35
+
36
+ # Disable optimization (use originals in docs)
37
+ IMAGE_OPTIMIZATION_ENABLED=false
38
+ ```
39
+
40
+ ### Quality Settings
41
+
42
+ ```bash
43
+ # Quality level 1-100 (default: 85)
44
+ # Higher = better quality, larger files
45
+ IMAGE_OPTIMIZATION_QUALITY=85
46
+
47
+ # Examples:
48
+ # - 60: Aggressive compression, visible artifacts (not recommended)
49
+ # - 75: Good compression, slight quality loss
50
+ # - 85: Balanced (recommended for web) ⭐
51
+ # - 95: Premium quality, minimal compression
52
+ # - 100: Maximum quality (only for PNG format)
53
+ ```
54
+
55
+ ### Output Format
56
+
57
+ ```bash
58
+ # Output format (default: webp)
59
+ IMAGE_OPTIMIZATION_FORMAT=webp
60
+
61
+ # Available formats:
62
+ # - webp: Modern format, best compression (recommended) ⭐
63
+ # - jpeg: Universal support, good compression
64
+ # - png: Lossless, larger files (use for diagrams with text)
65
+ ```
66
+
67
+ ### Maximum Dimensions
68
+
69
+ ```bash
70
+ # Maximum width in pixels (default: 1920)
71
+ IMAGE_OPTIMIZATION_MAX_WIDTH=1920
72
+
73
+ # Maximum height in pixels (default: 1920)
74
+ IMAGE_OPTIMIZATION_MAX_HEIGHT=1920
75
+
76
+ # Images larger than these dimensions will be resized
77
+ # Images smaller than these will NOT be enlarged
78
+ ```
79
+
80
+ ### Keep Originals
81
+
82
+ ```bash
83
+ # Keep original files (default: true)
84
+ IMAGE_OPTIMIZATION_KEEP_ORIGINAL=true
85
+
86
+ # If false, only optimized version is saved (not recommended)
87
+ ```
88
+
89
+ ## Recommended Configurations
90
+
91
+ ### Option A: Balanced Web (Default) ⭐
92
+
93
+ Best for documentation, blogs, and web content.
94
+
95
+ ```bash
96
+ IMAGE_OPTIMIZATION_ENABLED=true
97
+ IMAGE_OPTIMIZATION_QUALITY=85
98
+ IMAGE_OPTIMIZATION_FORMAT=webp
99
+ IMAGE_OPTIMIZATION_MAX_WIDTH=1920
100
+ IMAGE_OPTIMIZATION_MAX_HEIGHT=1920
101
+ IMAGE_OPTIMIZATION_KEEP_ORIGINAL=true
102
+ ```
103
+
104
+ **Results:**
105
+ - Quality: Excellent (nearly imperceptible loss)
106
+ - File size reduction: ~70%
107
+ - Original: 4.2 MB → Optimized: 1.2 MB
108
+
109
+ ### Option B: Premium Quality
110
+
111
+ For portfolios, high-end presentations, or when quality is critical.
112
+
113
+ ```bash
114
+ IMAGE_OPTIMIZATION_ENABLED=true
115
+ IMAGE_OPTIMIZATION_QUALITY=95
116
+ IMAGE_OPTIMIZATION_FORMAT=webp
117
+ IMAGE_OPTIMIZATION_MAX_WIDTH=2560
118
+ IMAGE_OPTIMIZATION_MAX_HEIGHT=2560
119
+ IMAGE_OPTIMIZATION_KEEP_ORIGINAL=true
120
+ ```
121
+
122
+ **Results:**
123
+ - Quality: Premium (virtually no visible loss)
124
+ - File size reduction: ~40%
125
+ - Original: 4.2 MB → Optimized: 2.5 MB
126
+
127
+ ### Option C: Print-Ready Documents
128
+
129
+ For documents intended for printing or when you need maximum quality.
130
+
131
+ ```bash
132
+ IMAGE_OPTIMIZATION_ENABLED=false
133
+ # When disabled, originals are used directly in documentation
134
+ ```
135
+
136
+ **Results:**
137
+ - Quality: Perfect (no loss)
138
+ - File size reduction: 0%
139
+ - Uses: Original PNG files
140
+
141
+ ### Option D: Diagrams with Text
142
+
143
+ Technical diagrams, screenshots, or images with text.
144
+
145
+ ```bash
146
+ IMAGE_OPTIMIZATION_ENABLED=true
147
+ IMAGE_OPTIMIZATION_QUALITY=95
148
+ IMAGE_OPTIMIZATION_FORMAT=png
149
+ IMAGE_OPTIMIZATION_MAX_WIDTH=2560
150
+ IMAGE_OPTIMIZATION_MAX_HEIGHT=2560
151
+ IMAGE_OPTIMIZATION_KEEP_ORIGINAL=true
152
+ ```
153
+
154
+ **Results:**
155
+ - Quality: Lossless
156
+ - File size reduction: ~15% (compression only)
157
+ - Best text clarity
158
+
159
+ ## Understanding File Sizes
160
+
161
+ | Optimization Level | File Size | Quality | Best For |
162
+ |-------------------|-----------|---------|----------|
163
+ | **Disabled** | 4.2 MB | 100% | Print, archival |
164
+ | **PNG Q100** | 3.6 MB | 100% | Diagrams with text |
165
+ | **WebP Q95** | 2.5 MB | 99% | Premium web |
166
+ | **WebP Q85** ⭐ | 1.2 MB | 98% | Standard web |
167
+ | **WebP Q75** | 800 KB | 95% | Fast loading |
168
+ | **JPEG Q85** | 1.5 MB | 98% | Universal support |
169
+
170
+ ## Quality Comparison
171
+
172
+ ### WebP vs JPEG vs PNG
173
+
174
+ **Same Visual Quality:**
175
+ - PNG (lossless): 4.2 MB
176
+ - WebP Q85: 1.2 MB (71% smaller than PNG)
177
+ - JPEG Q85: 1.5 MB (64% smaller than PNG)
178
+
179
+ **Verdict:** WebP provides the best compression with same perceived quality.
180
+
181
+ ### Quality Settings Visual Guide
182
+
183
+ - **Q100:** Perfect, no compression artifacts (only PNG)
184
+ - **Q95:** Premium, requires pixel-peeping to see difference
185
+ - **Q85:** Excellent, nearly imperceptible difference ⭐
186
+ - **Q75:** Good, slight softness on close inspection
187
+ - **Q60:** Noticeable compression artifacts (not recommended)
188
+
189
+ ## Accessing Original Files
190
+
191
+ Original files are always preserved in the `original/` subdirectory:
192
+
193
+ ```bash
194
+ # Web version (used in docs)
195
+ generated-images/gemini/diagram-001.webp
196
+
197
+ # Original (for print/archival)
198
+ generated-images/gemini/original/diagram-001.png
199
+ ```
200
+
201
+ To use originals in your documentation:
202
+
203
+ ```markdown
204
+ <!-- Use optimized (automatic) -->
205
+ ![Diagram](generated-images/gemini/diagram-001.webp)
206
+
207
+ <!-- Use original (manual override) -->
208
+ ![Diagram](generated-images/gemini/original/diagram-001.png)
209
+ ```
210
+
211
+ ## Troubleshooting
212
+
213
+ ### Sharp Library Not Available
214
+
215
+ If you see: `Sharp library not available - using original images`
216
+
217
+ **Solution:**
218
+ ```bash
219
+ npm install sharp
220
+ ```
221
+
222
+ Sharp requires native binaries and may need build tools on some systems.
223
+
224
+ ### Optimization Failing
225
+
226
+ If optimization fails, Visual Forge gracefully falls back to using originals.
227
+
228
+ Check logs for details:
229
+ ```
230
+ IMAGE_GEN_LOG_LEVEL=debug
231
+ ```
232
+
233
+ ### File Size Not Reducing
234
+
235
+ Possible causes:
236
+ 1. Image already optimized by provider
237
+ 2. Quality setting too high (95-100)
238
+ 3. PNG format selected (lossless)
239
+ 4. Image smaller than max dimensions
240
+
241
+ ### Want Different Settings Per Image
242
+
243
+ Currently, optimization settings are global. To use different settings:
244
+
245
+ 1. Generate images with one setting
246
+ 2. Change environment variables
247
+ 3. Regenerate specific images
248
+
249
+ Or manually optimize specific images:
250
+
251
+ ```typescript
252
+ import { optimizeImage } from '@michelabboud/visual-forge-mcp';
253
+
254
+ const result = await optimizeImage('path/to/image.png', {
255
+ quality: 95,
256
+ format: 'png',
257
+ keepOriginal: true,
258
+ });
259
+ ```
260
+
261
+ ## Performance Impact
262
+
263
+ Optimization adds minimal time to generation:
264
+
265
+ - Small images (< 1 MB): +0.5-1 second
266
+ - Medium images (1-3 MB): +1-2 seconds
267
+ - Large images (3-5 MB): +2-4 seconds
268
+
269
+ **Total workflow impact:** Typically < 5% increase in generation time.
270
+
271
+ ## Best Practices
272
+
273
+ 1. **Always keep originals** (`KEEP_ORIGINAL=true`)
274
+ 2. **Start with Q85** and adjust if needed
275
+ 3. **Use WebP** for best compression
276
+ 4. **Use PNG** for text-heavy diagrams
277
+ 5. **Disable for print** documents
278
+ 6. **Test settings** on sample images first
279
+
280
+ ## Examples
281
+
282
+ ### Web Documentation (Recommended)
283
+
284
+ ```bash
285
+ IMAGE_OPTIMIZATION_ENABLED=true
286
+ IMAGE_OPTIMIZATION_QUALITY=85
287
+ IMAGE_OPTIMIZATION_FORMAT=webp
288
+ ```
289
+
290
+ Result: Fast loading, excellent quality, significant file size savings.
291
+
292
+ ### Technical Diagrams
293
+
294
+ ```bash
295
+ IMAGE_OPTIMIZATION_ENABLED=true
296
+ IMAGE_OPTIMIZATION_QUALITY=95
297
+ IMAGE_OPTIMIZATION_FORMAT=png
298
+ ```
299
+
300
+ Result: Perfect text clarity, lossless quality.
301
+
302
+ ### Print-Ready
303
+
304
+ ```bash
305
+ IMAGE_OPTIMIZATION_ENABLED=false
306
+ ```
307
+
308
+ Result: Uses original PNG files directly.
309
+
310
+ ### Fast Loading Site
311
+
312
+ ```bash
313
+ IMAGE_OPTIMIZATION_ENABLED=true
314
+ IMAGE_OPTIMIZATION_QUALITY=75
315
+ IMAGE_OPTIMIZATION_FORMAT=webp
316
+ IMAGE_OPTIMIZATION_MAX_WIDTH=1280
317
+ IMAGE_OPTIMIZATION_MAX_HEIGHT=1280
318
+ ```
319
+
320
+ Result: Very fast loading, acceptable quality trade-off.
321
+
322
+ ## Statistics
323
+
324
+ After generation, check optimization results in logs:
325
+
326
+ ```
327
+ Image optimization successful
328
+ original: generated-images/gemini/original/diagram-001.png
329
+ optimized: generated-images/gemini/diagram-001.webp
330
+ originalSize: 4256.2 KB
331
+ optimizedSize: 1243.7 KB
332
+ reduction: 70.8%
333
+ ```
334
+
335
+ ## FAQ
336
+
337
+ **Q: Will optimization reduce print quality?**
338
+ A: No! Originals are always preserved in `original/` subdirectory. Use those for printing.
339
+
340
+ **Q: Can I disable optimization?**
341
+ A: Yes! Set `IMAGE_OPTIMIZATION_ENABLED=false` in your `.env` file.
342
+
343
+ **Q: What if Sharp fails to install?**
344
+ A: Visual Forge gracefully falls back to using original images without crashing.
345
+
346
+ **Q: Can I change settings per image?**
347
+ A: Currently global only. Change `.env` and regenerate specific images if needed.
348
+
349
+ **Q: What format should I use?**
350
+ A: WebP for web (best compression), PNG for diagrams with text.
351
+
352
+ **Q: Is WebP supported everywhere?**
353
+ A: Yes! WebP is supported in all modern browsers (Chrome, Firefox, Safari, Edge) since 2020.
354
+
355
+ **Q: How much space does this save?**
356
+ A: Typically 60-70% with Q85 WebP, while maintaining excellent visual quality.
357
+
358
+ ## Migration from Previous Versions
359
+
360
+ If you generated images before optimization was added:
361
+
362
+ 1. Your existing images are unaffected
363
+ 2. New images will automatically be optimized
364
+ 3. To optimize old images, regenerate them
365
+
366
+ ## Support
367
+
368
+ For issues or questions:
369
+ - GitHub Issues: https://github.com/michelabboud/visual-forge-mcp/issues
370
+ - Check logs with `IMAGE_GEN_LOG_LEVEL=debug`
@@ -0,0 +1,279 @@
1
+ # Visual Forge MCP - Complete Testing Guide
2
+
3
+ ## 🎯 Goal
4
+ Test the full Visual Forge MCP workflow on real files using `docs/example.md` which contains 6 image specifications.
5
+
6
+ ---
7
+
8
+ ## 📋 Pre-Test Checklist
9
+
10
+ ✅ MCP server added to `~/.claude/settings.json`
11
+ ✅ Server built (`dist/index.js` exists)
12
+ ✅ Test file ready: `docs/example.md` (6 image specs)
13
+
14
+ ---
15
+
16
+ ## 🔄 Step 1: Restart Claude Code
17
+
18
+ **You must restart Claude Code for the MCP server to load.**
19
+
20
+ Close this session and start a new one in this directory:
21
+ ```bash
22
+ cd /home/michel/projects/visual-forge-mcp
23
+ claude
24
+ ```
25
+
26
+ ---
27
+
28
+ ## 🧪 Step 2: Verify MCP Server Loaded
29
+
30
+ In your new Claude Code session, ask:
31
+
32
+ ```
33
+ "What MCP servers are available?"
34
+ ```
35
+
36
+ **Expected**: You should see `visual-forge` in the list.
37
+
38
+ ---
39
+
40
+ ## 🔧 Step 3: Configure a Provider
41
+
42
+ ### Option A: Check what's already configured
43
+
44
+ ```
45
+ "Check which image generation providers are configured"
46
+ ```
47
+
48
+ ### Option B: Configure Gemini (Recommended)
49
+
50
+ ```
51
+ "Configure my Gemini provider with API key: AIza..."
52
+ ```
53
+
54
+ (Replace with your actual Google API key from https://ai.google.dev)
55
+
56
+ **Alternative providers:**
57
+ - **Replicate** (cheapest at $0.003/image): `"Configure Replicate with API key: r8_..."`
58
+ - **OpenAI**: `"Configure OpenAI with API key: sk-..."`
59
+
60
+ ---
61
+
62
+ ## 📄 Step 4: Parse the Example File
63
+
64
+ ```
65
+ "Parse the file docs/example.md to extract image specifications"
66
+ ```
67
+
68
+ **Expected Result:**
69
+ - ✅ 6 image specifications found
70
+ - Types: hero, architecture, flowchart, diagram, icon, screenshot
71
+
72
+ ---
73
+
74
+ ## 👀 Step 5: List Parsed Images
75
+
76
+ ```
77
+ "Show me all the parsed image specifications"
78
+ ```
79
+
80
+ **You should see:**
81
+ 1. Hero image (16:9) - Developer workspace
82
+ 2. Architecture diagram (16:9) - Microservices
83
+ 3. Flow chart (4:3) - Authentication flow
84
+ 4. Technical diagram (16:9) - Data pipeline
85
+ 5. Icon set (1:1) - 4 feature icons
86
+ 6. Screenshot (16:9) - Dashboard UI
87
+
88
+ ---
89
+
90
+ ## 🎨 Step 6: Generate a Single Test Image
91
+
92
+ ```
93
+ "Generate the hero image using Gemini provider"
94
+ ```
95
+
96
+ **Expected:**
97
+ - ✅ Image generated successfully
98
+ - 📁 Saved to: `generated-images/gemini/hero-img-01.png`
99
+ - 💰 Cost: ~$0.039
100
+ - ⏱️ Time: ~5-10 seconds
101
+
102
+ ---
103
+
104
+ ## 🔍 Step 7: Verify the Generated Image
105
+
106
+ ```
107
+ "Show me the generated image file path and metadata"
108
+ ```
109
+
110
+ Then check the actual file:
111
+ ```bash
112
+ ls -lh generated-images/gemini/
113
+ open generated-images/gemini/hero-img-01.png # or use your image viewer
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 🚀 Step 8: Generate All Images (Full Workflow)
119
+
120
+ Now let's generate all 6 images in bulk mode:
121
+
122
+ ```
123
+ "Start a bulk workflow to generate all remaining images using Gemini provider with concurrency of 2"
124
+ ```
125
+
126
+ **Expected:**
127
+ - ⚡ 2 images generating in parallel
128
+ - 📊 Progress updates
129
+ - 💰 Total cost: ~$0.234 (6 × $0.039)
130
+ - ⏱️ Total time: ~30-40 seconds
131
+
132
+ ---
133
+
134
+ ## 📊 Step 9: Check Status and Progress
135
+
136
+ While images are generating:
137
+
138
+ ```
139
+ "What's the current generation status?"
140
+ ```
141
+
142
+ ---
143
+
144
+ ## 💰 Step 10: Get Cost Summary
145
+
146
+ After all images complete:
147
+
148
+ ```
149
+ "Show me the cost summary for all generated images"
150
+ ```
151
+
152
+ **Expected:**
153
+ ```json
154
+ {
155
+ "gemini": {
156
+ "count": 6,
157
+ "totalCost": 0.234
158
+ }
159
+ }
160
+ ```
161
+
162
+ ---
163
+
164
+ ## 🔄 Step 11: Test Different Provider
165
+
166
+ Let's generate the same hero image with a different provider to compare:
167
+
168
+ ```
169
+ "Configure my Replicate API key: r8_..."
170
+ "Generate the hero image again but use Replicate provider"
171
+ ```
172
+
173
+ Now you'll have two versions to compare:
174
+ - `generated-images/gemini/hero-img-01.png`
175
+ - `generated-images/replicate/hero-img-01.png`
176
+
177
+ ---
178
+
179
+ ## 🎯 Step 12: Advanced - Test Configuration Tools
180
+
181
+ ### Test Connection
182
+ ```
183
+ "Test if my Gemini connection is working"
184
+ ```
185
+
186
+ ### Get Provider Status
187
+ ```
188
+ "Show me the status of all configured providers"
189
+ ```
190
+
191
+ ### Remove Provider (Optional)
192
+ ```
193
+ "Remove my OpenAI provider configuration"
194
+ ```
195
+
196
+ ---
197
+
198
+ ## 📁 Expected File Structure After Testing
199
+
200
+ ```
201
+ generated-images/
202
+ ├── gemini/
203
+ │ ├── hero-img-01.png
204
+ │ ├── architecture-img-01.png
205
+ │ ├── flowchart-img-01.png
206
+ │ ├── diagram-img-01.png
207
+ │ ├── icon-img-01.png
208
+ │ └── screenshot-img-01.png
209
+ └── replicate/ (if you tested with Replicate)
210
+ └── hero-img-01.png
211
+ ```
212
+
213
+ ---
214
+
215
+ ## ✅ Success Criteria
216
+
217
+ - [x] MCP server loads successfully
218
+ - [x] Can configure providers via MCP tools
219
+ - [x] Can test provider connections
220
+ - [x] Can parse markdown files
221
+ - [x] Can list parsed image specs
222
+ - [x] Can generate single images
223
+ - [x] Can generate bulk images with workflows
224
+ - [x] Can check status and progress
225
+ - [x] Can get cost summaries
226
+ - [x] Images saved in correct directories
227
+ - [x] Rate limiting works (no API bans)
228
+
229
+ ---
230
+
231
+ ## 🐛 Troubleshooting
232
+
233
+ ### Server Not Loading
234
+ ```bash
235
+ # Check if server built correctly
236
+ ls -la dist/index.js
237
+ cat ~/.claude/settings.json | grep visual-forge
238
+
239
+ # Rebuild if needed
240
+ npm run build
241
+ ```
242
+
243
+ ### Provider Configuration Issues
244
+ ```
245
+ "Show me which providers need configuration"
246
+ "Check the provider status"
247
+ ```
248
+
249
+ ### Generation Errors
250
+ - Check API key is valid
251
+ - Verify provider has credits/quota
252
+ - Check rate limits aren't exceeded
253
+ - Review error messages in logs
254
+
255
+ ---
256
+
257
+ ## 📝 Notes for Real Use
258
+
259
+ 1. **Start with free/cheap providers** (Gemini, Replicate) for testing
260
+ 2. **Use bulk mode** for efficiency (parallel generation)
261
+ 3. **Monitor costs** regularly with cost_summary tool
262
+ 4. **Rate limiter protects you** - don't worry about API bans
263
+ 5. **Images are organized** by provider in `generated-images/`
264
+ 6. **State is persistent** - you can pause and resume workflows
265
+
266
+ ---
267
+
268
+ ## 🎉 After Testing
269
+
270
+ Once you've completed these steps:
271
+ 1. Review the generated images
272
+ 2. Compare quality between providers
273
+ 3. Check actual costs vs estimates
274
+ 4. Verify all MCP tools work correctly
275
+ 5. Test edge cases (invalid keys, missing files, etc.)
276
+
277
+ ---
278
+
279
+ **Ready to test? Restart Claude Code and follow the steps above!** 🚀