Skip to content

Commit da21ca0

Browse files
committed
feat: Mandatory JPG generation with SVG provider
SVG generation now ALWAYS produces both .svg and .jpg files. GitHub requires a raster image (JPG/PNG) for social preview settings, so the JPG is mandatory for actual use. - SVG: editable source file (10-50KB) - JPG: for GitHub upload (1280x640, quality 90, <1MB) Updated: - SKILL.md with mandatory conversion step - commands/social-preview.md with dual output - commands/all.md with JPG in summary - config-svg.md example with expected outputs - CHANGELOG.md with new feature
1 parent b7a9c93 commit da21ca0

5 files changed

Lines changed: 119 additions & 48 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- **[social-preview]**: Mandatory JPG generation with SVG provider
13+
- SVG generation now ALWAYS produces both `.svg` and `.jpg` files
14+
- JPG is required for GitHub social preview (GitHub doesn't accept SVG)
15+
- JPG specs: 1280x640, quality 90, < 1MB
16+
- Both files uploaded when using `--upload` flag
17+
1018
### Fixed
1119

1220
- **[setup]**: Updated setup wizard with SVG-first provider options

commands/all.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,17 @@ Generate social preview based on provider:
7171

7272
**SVG (default)**:
7373
- Generate clean SVG using domain templates
74-
- Save to `.github/social-preview.svg`
75-
- If `--dark-mode`, generate dark variant
74+
- Save SVG to `.github/social-preview.svg`
75+
- **MANDATORY: Convert to JPG** (`.github/social-preview.jpg`)
76+
- Dimensions: 1280x640, Quality: 90, Size: < 1MB
77+
- If `--dark-mode`, generate dark variants (SVG + JPG)
7678

7779
**DALL-E 3 / Gemini**:
7880
- Generate optimized image prompt
7981
- Call API and save PNG
8082
- Save to `.github/social-preview.png`
8183

82-
Output the generated file location (or prompt if manual).
84+
Output the generated file locations (SVG + JPG for SVG provider, or prompt if manual).
8385

8486
#### Step 4c: README Enhancement
8587

@@ -104,8 +106,9 @@ Display complete summary:
104106
105107
### Social Preview
106108
- Provider: svg (default)
107-
- Output: .github/social-preview.svg
108-
- Size: X KB
109+
- SVG Output: .github/social-preview.svg (X KB)
110+
- JPG Output: .github/social-preview.jpg (X KB) - **For GitHub upload**
111+
- Dimensions: 1280x640
109112
- [Generated/Pending]
110113
111114
### README Enhancement
@@ -145,10 +148,12 @@ If `--apply` flag or user confirms:
145148

146149
| Provider | Social Preview | Infographic | Cost | Speed |
147150
|----------|---------------|-------------|------|-------|
148-
| **svg** (default) | SVG file | SVG file | Free | Instant |
151+
| **svg** (default) | SVG + JPG | SVG file | Free | Instant |
149152
| **dalle-3** | PNG image | PNG image | ~$0.16 | 10-30s |
150153
| **gemini** | PNG image | PNG image | ~$0.08 | 6-20s |
151154

155+
**Note**: SVG provider always generates both `.svg` (editable) and `.jpg` (for GitHub upload).
156+
152157
## Example Usage
153158

154159
```bash
@@ -179,9 +184,10 @@ If `--apply` flag or user confirms:
179184

180185
- Run without `--apply` first to review changes
181186
- SVG generation is free and instant (recommended default)
187+
- SVG always generates JPG for GitHub compatibility
182188
- Ensure `gh` CLI is authenticated for metadata updates
183189
- Configure `.claude/github-social.local.md` for custom settings
184-
- Social preview requires manual GitHub settings update after upload
190+
- Social preview requires selecting the **JPG** in GitHub settings
185191
- Use `--dark-mode` for repositories viewed in both themes
186192

187193
## Related Commands

commands/social-preview.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ The image must meet GitHub's social preview requirements:
1717
- Minimum: 640x320 pixels
1818
- Recommended: 1280x640 pixels (2:1 aspect ratio)
1919
- Maximum file size: 1MB
20-
- Output location: `.github/social-preview.svg` (default) or `.github/social-preview.png`
20+
- Output locations:
21+
- `.github/social-preview.svg` - Editable source file
22+
- `.github/social-preview.jpg` - **Always generated** (required for GitHub upload)
23+
24+
**IMPORTANT**: GitHub requires a raster image (JPG/PNG) for social preview. SVG generation ALWAYS produces both SVG and JPG files.
2125

2226
## Process
2327

@@ -58,8 +62,12 @@ Use the social-preview skill based on provider setting:
5862
1. Design visual concept based on project domain
5963
2. Generate clean SVG following domain templates
6064
3. Apply svg_style (minimal, geometric, illustrated)
61-
4. Save to output path (`.github/social-preview.svg`)
62-
5. If `dark_mode: both`, generate dark variant as well
65+
4. Save SVG to output path (`.github/social-preview.svg`)
66+
5. **MANDATORY: Convert SVG to JPG** (`.github/social-preview.jpg`)
67+
- Dimensions: 1280x640
68+
- Quality: 90
69+
- File size: < 1MB
70+
6. If `dark_mode: both`, generate dark variants (SVG and JPG)
6371

6472
**For DALL-E 3** (`--provider=dalle-3`):
6573
1. Verify `OPENAI_API_KEY` is available
@@ -88,12 +96,13 @@ If upload is requested:
8896

8997
### 5. Report Results
9098

91-
**If SVG generated**:
92-
- Confirm file location and size
93-
- Display the SVG content (or path)
94-
- If `dark_mode: both`, report both variants
99+
**If SVG generated** (always includes JPG):
100+
- Confirm SVG file location and size
101+
- **Confirm JPG file location and size** (for GitHub upload)
102+
- Report dimensions (1280x640)
103+
- If `dark_mode: both`, report all variants (SVG + JPG for each)
95104

96-
**If image generated (PNG)**:
105+
**If AI-generated image (DALL-E/Gemini)**:
97106
- Confirm file location
98107
- Report dimensions and file size
99108
- If uploaded: provide commit URL
@@ -107,11 +116,13 @@ If upload is requested:
107116

108117
| Provider | Output | Cost | Speed | Quality |
109118
|----------|--------|------|-------|---------|
110-
| **svg** (default) | SVG file | Free | Instant | Clean, predictable |
119+
| **svg** (default) | SVG + JPG | Free | Instant | Clean, predictable |
111120
| **dalle-3** | PNG image | ~$0.08 | 5-15s | Artistic, varied |
112121
| **gemini** | PNG image | ~$0.039 | 3-10s | Good quality |
113122
| **manual** | Text prompt | Free | Instant | N/A |
114123

124+
**Note**: SVG provider always generates both `.svg` (editable source) and `.jpg` (for GitHub upload).
125+
115126
## Example Usage
116127

117128
```bash
@@ -140,13 +151,15 @@ If upload is requested:
140151
## GitHub Upload Instructions
141152

142153
If `--upload` was used:
143-
- The image has been committed to the repository
144-
- Direct user to repository Settings → General → Social preview to select the uploaded image
154+
- Both SVG and JPG have been committed to the repository
155+
- Direct user to repository Settings → General → Social preview to select the **JPG** image
145156

146157
If manual upload needed:
147158
1. Go to repository Settings
148159
2. Under "Social preview", click "Edit"
149-
3. Upload the generated image
160+
3. Upload the **JPG** file (`.github/social-preview.jpg`)
150161
4. Save changes
151162

163+
**Important**: GitHub requires a raster image (JPG/PNG) for social preview. Upload the `.jpg` file, not the `.svg`.
164+
152165
The image will appear when the repository is shared on social media platforms.

skills/social-preview/SKILL.md

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ All generated images must meet GitHub's social preview requirements:
2020
- **Minimum**: 640x320 pixels
2121
- **Recommended**: 1280x640 pixels (2:1 aspect ratio)
2222
- **Maximum file size**: 1MB
23-
- **Formats**: SVG (default), PNG, JPG, GIF
24-
- **Default output**: `.github/social-preview.svg`
23+
- **Formats**: JPG (required for GitHub), SVG (source file)
24+
- **Default outputs**:
25+
- `.github/social-preview.svg` - Editable source file
26+
- `.github/social-preview.jpg` - **Always generated** for GitHub upload
27+
28+
**IMPORTANT**: GitHub's social preview setting requires a raster image (JPG/PNG). SVG generation MUST ALWAYS also produce a JPG file.
2529

2630
## Workflow
2731

@@ -180,10 +184,22 @@ If `dark_mode: true` or `dark_mode: both`:
180184
- Adjust accent colors for dark backgrounds
181185
- If `both`: save as `[name].svg` and `[name]-dark.svg`
182186

183-
**Save SVG**:
187+
**Save SVG and Convert to JPG**:
184188
1. Write SVG content to `output_path` (default: `.github/social-preview.svg`)
185-
2. Verify file size < 50KB (warn if larger)
186-
3. If `dark_mode: both`, generate and save dark variant
189+
2. Verify SVG file size < 50KB (warn if larger)
190+
3. **MANDATORY: Convert SVG to JPG**:
191+
```bash
192+
# Convert SVG to JPG at 1280x640, quality 90
193+
convert .github/social-preview.svg -resize 1280x640! -quality 90 -background white -flatten .github/social-preview.jpg
194+
```
195+
4. Verify JPG meets requirements:
196+
- Dimensions: 1280x640
197+
- File size: < 1MB (compress if needed)
198+
5. If `dark_mode: both`, generate dark variant SVG and JPG:
199+
- `.github/social-preview-dark.svg`
200+
- `.github/social-preview-dark.jpg`
201+
202+
**Note**: The JPG is the file to upload to GitHub's social preview setting. The SVG is kept as an editable source.
187203

188204
---
189205

@@ -286,21 +302,26 @@ Negative prompt: text, watermarks, realistic photos, cluttered, busy patterns
286302

287303
### Step 5: Verify Output
288304

289-
**For SVG output**:
305+
**For SVG output** (always accompanied by JPG):
290306
1. Verify valid XML structure
291-
2. Check file size < 50KB (warn if 50-100KB, error if >100KB)
307+
2. Check SVG file size < 50KB (warn if 50-100KB, error if >100KB)
292308
3. Verify viewBox is 1280x640
309+
4. **Verify JPG was created**:
310+
- File exists at `.github/social-preview.jpg`
311+
- Dimensions are exactly 1280x640
312+
- File size is under 1MB
313+
- If exceeds 1MB, recompress with lower quality
293314

294-
**For image output (PNG/JPG)**:
315+
**For AI-generated image output (PNG/JPG from DALL-E/Gemini)**:
295316
1. Verify file exists at output path
296-
2. Check dimensions meet requirements (≥640x320)
317+
2. Check dimensions meet requirements (≥640x320, recommended 1280x640)
297318
3. Check file size is under 1MB
298319
4. If exceeds 1MB, compress progressively
299320

300321
**Report success with**:
301-
- File location
302-
- File size
303-
- Dimensions
322+
- SVG file location and size
323+
- **JPG file location and size** (for GitHub upload)
324+
- Dimensions (1280x640)
304325
- Provider used
305326

306327
### Step 6: Upload to Repository (Optional)
@@ -311,34 +332,45 @@ If `upload_to_repo: true` is configured (or `--upload` flag provided):
311332
- Parse `git remote get-url origin` to extract owner and repo name
312333
- Determine current branch with `git branch --show-current`
313334

314-
2. **Prepare upload**:
315-
- Read the generated file
335+
2. **Prepare upload** (upload BOTH files):
336+
- Read the SVG source file and JPG output file
316337
- Encode content as base64 for GitHub API
317338

318-
3. **Check for existing file**:
319-
- Use GitHub API to check if output file exists
320-
- If exists, retrieve the SHA for update operation
339+
3. **Check for existing files**:
340+
- Use GitHub API to check if files exist
341+
- If exist, retrieve the SHA for update operation
321342

322-
4. **Upload via GitHub MCP tool**:
323-
Use `mcp__github__create_or_update_file` with:
343+
4. **Upload via GitHub MCP tool** (both SVG and JPG):
324344
```yaml
345+
# Upload JPG (for GitHub social preview)
325346
owner: [detected owner]
326347
repo: [detected repo]
327-
path: [output_path]
328-
content: [base64 encoded content]
348+
path: .github/social-preview.jpg
349+
content: [base64 encoded JPG]
329350
message: "chore: update social preview image"
330351
branch: [current or default branch]
331352
sha: [existing file SHA if updating]
332353
```
354+
```yaml
355+
# Upload SVG (editable source)
356+
owner: [detected owner]
357+
repo: [detected repo]
358+
path: .github/social-preview.svg
359+
content: [base64 encoded SVG]
360+
message: "chore: update social preview source SVG"
361+
branch: [current or default branch]
362+
sha: [existing file SHA if updating]
363+
```
333364
334365
5. **Report upload status**:
335-
- Confirm successful upload with commit URL
366+
- Confirm successful upload with commit URLs
367+
- **Remind user**: The JPG file is what should be selected in GitHub settings
336368
- Provide GitHub settings link for activating the social preview
337369
338370
**Note**: To set as actual social preview, users must:
339371
1. Go to repository Settings → General
340372
2. Scroll to "Social preview"
341-
3. Click "Edit" and select the uploaded image
373+
3. Click "Edit" and select the **JPG** image (`.github/social-preview.jpg`)
342374

343375
## Color Palettes by Domain
344376

skills/social-preview/examples/config-svg.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Example configuration for using SVG generation, the default and recommended provider.
44

5+
**Note**: SVG generation ALWAYS produces both `.svg` (editable source) and `.jpg` (for GitHub upload).
6+
57
## Configuration
68

79
```yaml
@@ -54,8 +56,10 @@ dark_mode: both
5456
```
5557
5658
This creates:
57-
- `.github/social-preview.svg` (light)
58-
- `.github/social-preview-dark.svg` (dark)
59+
- `.github/social-preview.svg` (light SVG)
60+
- `.github/social-preview.jpg` (light JPG - for GitHub upload)
61+
- `.github/social-preview-dark.svg` (dark SVG)
62+
- `.github/social-preview-dark.jpg` (dark JPG)
5963

6064
## Expected Behavior
6165

@@ -65,19 +69,27 @@ When running `/social-preview`:
6569
2. Domain is detected (DevTools, AI, Web, etc.)
6670
3. Appropriate color palette is selected
6771
4. SVG is generated using domain template
68-
5. File is saved to output path
69-
6. File location and size are reported
72+
5. SVG is saved to `.github/social-preview.svg`
73+
6. **JPG is generated** from SVG (1280x640, quality 90)
74+
7. JPG is saved to `.github/social-preview.jpg`
75+
8. Both file locations and sizes are reported
76+
77+
**Output Files**:
78+
- `.github/social-preview.svg` - Editable source (10-50KB)
79+
- `.github/social-preview.jpg` - For GitHub upload (<1MB)
7080

7181
## Benefits of SVG
7282

7383
| Feature | Value |
7484
|---------|-------|
7585
| Cost | Free |
7686
| Speed | Instant |
77-
| File Size | 10-50KB |
78-
| Editability | Full (text-based) |
87+
| SVG File Size | 10-50KB |
88+
| JPG File Size | 50-200KB |
89+
| Editability | Full (SVG is text-based) |
7990
| Consistency | 100% predictable |
8091
| Dark Mode | Easy variants |
92+
| GitHub Compatible | JPG always generated |
8193

8294
## Domain Color Palettes
8395

0 commit comments

Comments
 (0)