Skip to content

Commit 43cadff

Browse files
committed
docs: add more pages
1 parent a2873b0 commit 43cadff

File tree

5 files changed

+1315
-0
lines changed

5 files changed

+1315
-0
lines changed

docs/features/app-icons.md

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# App Icon Generation
2+
3+
imgx provides powerful tools for generating app icons for iOS, macOS, and other platforms from a single source image.
4+
5+
## Overview
6+
7+
When developing applications, you need icons in various sizes for different platforms, devices, and contexts. Creating these manually is time-consuming and error-prone. imgx automates this process, generating all required icon sizes from a single high-resolution source image.
8+
9+
## Supported Platforms
10+
11+
- **iOS**: All icon sizes required for iPhone and iPad apps, including App Store icons
12+
- **macOS**: App icons for Mac applications, including the .icns format
13+
- **Web**: Favicon sets including various sizes and formats
14+
- **Android**: Coming soon (currently in beta)
15+
16+
## Basic Usage
17+
18+
### CLI
19+
20+
```bash
21+
# Generate all app icons (iOS and macOS) from a single image
22+
imgx app-icon source-icon.png
23+
24+
# Generate only iOS app icons
25+
imgx app-icon source-icon.png --platform ios
26+
27+
# Generate only macOS app icons
28+
imgx app-icon source-icon.png --platform macos
29+
30+
# Specify output directory
31+
imgx app-icon source-icon.png --output-dir ./assets/app-icons
32+
```
33+
34+
### JavaScript/TypeScript API
35+
36+
```ts
37+
import { createAppIcon } from '@stacksjs/imgx'
38+
39+
// Generate all app icons
40+
const result = await createAppIcon('path/to/source-icon.png')
41+
42+
// Generate only iOS icons
43+
const iosIcons = await createAppIcon('path/to/source-icon.png', {
44+
platform: 'ios',
45+
outputDir: './public/app-icons',
46+
})
47+
48+
console.log(`Generated ${iosIcons.sizes.length} icons for ${iosIcons.platform}`)
49+
```
50+
51+
## Source Image Requirements
52+
53+
For best results, your source image should meet these requirements:
54+
55+
- **Resolution**: At least 1024×1024 pixels (higher is better)
56+
- **Format**: PNG with transparency
57+
- **Content**: Place important content within the center 80% of the image (avoid corners)
58+
- **Style**: Follow platform-specific guidelines (i.e., rounded corners for iOS)
59+
- **Color**: Vibrant, distinctive and legible at small sizes
60+
61+
## Generated Icons
62+
63+
### iOS Icons
64+
65+
imgx generates all iOS app icon sizes required by Apple, including:
66+
67+
| Size | Purpose |
68+
|------|---------|
69+
| 20×20 pt @1x, @2x, @3x | Notification icon |
70+
| 29×29 pt @1x, @2x, @3x | Settings icon |
71+
| 40×40 pt @1x, @2x, @3x | Spotlight icon |
72+
| 60×60 pt @2x, @3x | iPhone app icon |
73+
| 76×76 pt @1x, @2x | iPad app icon |
74+
| 83.5×83.5 pt @2x | iPad Pro app icon |
75+
| 1024×1024 px | App Store icon |
76+
77+
The output includes a properly formatted `Contents.json` file for use in Xcode projects.
78+
79+
### macOS Icons
80+
81+
For macOS applications, imgx generates:
82+
83+
| Size | Purpose |
84+
|------|---------|
85+
| 16×16 pt @1x, @2x | Menu bar, Spotlight, Finder |
86+
| 32×32 pt @1x, @2x | Finder, Desktop |
87+
| 128×128 pt @1x, @2x | Finder, File Info |
88+
| 256×256 pt @1x, @2x | Finder, File Info |
89+
| 512×512 pt @1x, @2x | App Store |
90+
91+
The output includes a `.icns` file that can be used directly in macOS applications.
92+
93+
## Output Structure
94+
95+
By default, imgx creates this directory structure:
96+
97+
```
98+
output-dir/
99+
├── ios/
100+
│ ├── AppIcon.appiconset/
101+
│ │ ├── Contents.json
102+
│ │ ├── [email protected]
103+
│ │ ├── [email protected]
104+
│ │ ├── ... (all other iOS sizes)
105+
│ │ └── Icon-1024.png
106+
├── macos/
107+
│ ├── AppIcon.appiconset/
108+
│ │ ├── Contents.json
109+
│ │ ├── Icon-16.png
110+
│ │ ├── [email protected]
111+
│ │ ├── ... (all other macOS sizes)
112+
│ │ └── [email protected]
113+
│ └── AppIcon.icns
114+
```
115+
116+
## Advanced Usage
117+
118+
### Custom Background
119+
120+
For platforms that don't support transparency (like iOS App Store), you can specify a background color:
121+
122+
```bash
123+
imgx app-icon icon.png --background "#ffffff"
124+
```
125+
126+
```ts
127+
await createAppIcon('icon.png', {
128+
background: '#ffffff', // or 'rgba(255, 255, 255, 0.5)' for semi-transparent
129+
})
130+
```
131+
132+
### Custom Filename Template
133+
134+
You can customize the filename pattern:
135+
136+
```bash
137+
imgx app-icon icon.png --filename-template "custom-[size]@[scale]x.[ext]"
138+
```
139+
140+
```ts
141+
await createAppIcon('icon.png', {
142+
filenameTemplate: 'custom-[size]@[scale]x.[ext]',
143+
})
144+
```
145+
146+
Available placeholders:
147+
- `[size]`: Icon size (e.g., 20, 29, 40)
148+
- `[scale]`: Scale factor (1, 2, 3)
149+
- `[ext]`: File extension (png)
150+
- `[platform]`: Platform name (ios, macos)
151+
152+
### Generating Specific Sizes
153+
154+
You can generate only specific sizes if needed:
155+
156+
```bash
157+
imgx app-icon icon.png --platform ios --sizes 20,29,40
158+
```
159+
160+
```ts
161+
await createAppIcon('icon.png', {
162+
platform: 'ios',
163+
sizes: [20, 29, 40], // Only generate these sizes
164+
})
165+
```
166+
167+
## Integration with Xcode
168+
169+
The generated iOS and macOS AppIcon.appiconset directories can be directly used in Xcode:
170+
171+
1. Generate the icons using imgx
172+
2. Drag the entire `.appiconset` folder into your Xcode project
173+
3. Select your target and set the AppIcon set as your app icon
174+
175+
## Configuration
176+
177+
You can set default app icon generation options in your imgx.config.ts file:
178+
179+
```ts
180+
// imgx.config.ts
181+
export default {
182+
appIcon: {
183+
outputDir: 'assets/app-icons',
184+
platform: 'all', // 'ios', 'macos', or 'all'
185+
background: '#ffffff', // Background for non-transparent contexts
186+
filenameTemplate: 'Icon-[size]@[scale]x.[ext]',
187+
},
188+
}
189+
```

0 commit comments

Comments
 (0)