generate-icon
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGenerate Icon Skill
图标生成Skill
Generate professional icons for any platform using Gemini AI with automatic background removal, cropping, and multi-size export.
借助Gemini AI生成适用于任意平台的专业图标,自动完成背景移除、裁剪和多尺寸导出。
Quick Start
快速开始
bash
undefinedbash
undefinedFavicon for website
网站favicon
bun run icon "modern tech startup logo letter S" --preset favicon --output ./icons/favicon
bun run icon "modern tech startup logo letter S" --preset favicon --output ./icons/favicon
iOS App Store icons
iOS App Store图标
bun run icon "meditation app lotus flower" --preset apple-app-icon --output ./icons/ios
bun run icon "meditation app lotus flower" --preset apple-app-icon --output ./icons/ios
Android Play Store + adaptive icons
Android Play Store + 自适应图标
bun run icon "fitness tracker flame icon" --preset android-app-icon --output ./icons/android
bun run icon "fitness tracker flame icon" --preset android-app-icon --output ./icons/android
PWA manifest icons
PWA清单图标
bun run icon "productivity app checkmark" --preset pwa --output ./icons/pwa
bun run icon "productivity app checkmark" --preset pwa --output ./icons/pwa
macOS desktop app
macOS桌面应用图标
bun run icon "code editor brackets symbol" --preset macos-icns --output ./icons/macos
bun run icon "code editor brackets symbol" --preset macos-icns --output ./icons/macos
Windows desktop app
Windows桌面应用图标
bun run icon "music player note icon" --preset windows-ico --output ./icons/windows
bun run icon "music player note icon" --preset windows-ico --output ./icons/windows
General UI icons
通用UI图标
bun run icon "settings gear" --preset ui-icons --output ./icons/ui
undefinedbun run icon "settings gear" --preset ui-icons --output ./icons/ui
undefinedPresets
预设配置
| Preset | Description | Sizes | Bundle |
|---|---|---|---|
| iOS/iPadOS App Store | 18 sizes (1024-20px) | No |
| Google Play + adaptive layers | 11 sizes + foreground | No |
| Browser tab icons | 8 sizes + ICO | Yes (.ico) |
| Progressive Web App | 11 sizes + maskable | No |
| macOS desktop | 10 sizes | Yes (.icns) |
| Windows desktop | 7 sizes | Yes (.ico) |
| In-app icons | 9 sizes (512-16px) | No |
| 预设配置 | 说明 | 尺寸 | 打包 |
|---|---|---|---|
| iOS/iPadOS App Store图标 | 18种尺寸(1024-20px) | 否 |
| Google Play图标 + 自适应图层 | 11种尺寸 + 前景层 | 否 |
| 浏览器标签页图标 | 8种尺寸 + ICO格式 | 是(.ico) |
| 渐进式Web应用图标 | 11种尺寸 + 可遮罩图标 | 否 |
| macOS桌面应用图标 | 10种尺寸 | 是(.icns) |
| Windows桌面应用图标 | 7种尺寸 | 是(.ico) |
| 应用内UI图标 | 9种尺寸(512-16px) | 否 |
Pipeline
处理流程
- Generate - Creates master icon at high resolution via Gemini
- Remove Background - Uses Replicate rembg for clean edges
- Crop & Center - Trims whitespace, centers on square canvas with 5% padding
- Resize - Exports all preset sizes with lanczos3 interpolation
- Bundle - Creates ICO/ICNS bundles where needed
- 生成 - 通过Gemini生成高分辨率的主图标
- 移除背景 - 使用Replicate的rembg工具实现边缘清晰的背景移除
- 裁剪与居中 - 去除空白区域,在方形画布上居中图标并保留5%内边距
- 调整尺寸 - 使用lanczos3插值算法导出所有预设尺寸的图标
- 打包 - 按需创建ICO/ICNS格式的图标包
Options
选项参数
bun run icon "prompt" --preset <name> --output <dir> [options]
Required:
--preset <name> Platform preset (see table above)
--output <dir> Output directory
Optional:
--input <image> Reference image for style guidance
--master-image <path> Use existing master instead of generating
--skip-generate Skip AI generation (requires --master-image)
--skip-remove-bg Skip background removal
--bg-color <hex> Background color for non-transparent presetsbun run icon "提示词" --preset <名称> --output <目录> [可选参数]
必填参数:
--preset <名称> 平台预设配置(见上表)
--output <目录> 输出目录
可选参数:
--input <图片> 用于风格参考的图片
--master-image <路径> 使用已有的主图标,而非重新生成
--skip-generate 跳过AI生成步骤(需配合--master-image使用)
--skip-remove-bg 跳过背景移除步骤
--bg-color <十六进制值> 非透明预设配置的背景颜色Examples
示例
Using a reference image
使用参考图片
bash
bun run icon "clean app icon version" --preset pwa --input ./existing-logo.png --output ./iconsbash
bun run icon "clean app icon version" --preset pwa --input ./existing-logo.png --output ./iconsUsing an existing master
使用已有主图标
bash
bun run icon "" --preset ui-icons --master-image ./my-icon.png --skip-generate --output ./iconsbash
bun run icon "" --preset ui-icons --master-image ./my-icon.png --skip-generate --output ./iconsiOS with custom background color
带自定义背景色的iOS图标
bash
bun run icon "weather app sun" --preset apple-app-icon --bg-color "#0066CC" --output ./icons/iosbash
bun run icon "weather app sun" --preset apple-app-icon --bg-color "#0066CC" --output ./icons/iosIcon Design Tips
图标设计技巧
DO:
- Simple, bold, recognizable silhouette
- Single focal point
- High contrast
- Clean edges
- Works at 16x16px
DON'T:
- Fine details that disappear at small sizes
- Text (unreadable at icon sizes)
- Complex gradients (banding issues)
- Multiple competing elements
- Photos or realistic images
建议:
- 采用简洁、醒目、易识别的轮廓
- 单一视觉焦点
- 高对比度
- 边缘清晰
- 在16x16px尺寸下仍可正常显示
避免:
- 小尺寸下会消失的精细细节
- 文字(图标尺寸下无法阅读)
- 复杂渐变(会出现色带问题)
- 多个相互竞争的元素
- 照片或写实风格图像
Environment Variables
环境变量
| Variable | Required | Description |
|---|---|---|
| Yes | Google AI Studio API key |
| Yes | Replicate API token for background removal |
| 变量 | 是否必填 | 说明 |
|---|---|---|
| 是 | Google AI Studio的API密钥 |
| 是 | 用于背景移除的Replicate API令牌 |
Output Structure
输出结构
output/
├── master-raw.png # Original generated image
├── master-nobg.png # Background removed
├── master-cropped.png # Cropped and centered
├── master-final.png # With background (iOS only)
├── favicon.ico # ICO bundle (favicon preset)
├── AppIcon.icns # ICNS bundle (macos preset)
├── icon-512.png # Size variants...
├── icon-256.png
└── ...output/
├── master-raw.png # 原始生成的图片
├── master-nobg.png # 已移除背景的图片
├── master-cropped.png # 已裁剪并居中的图片
├── master-final.png # 带背景的图片(仅iOS预设)
├── favicon.ico # ICO格式图标包(favicon预设)
├── AppIcon.icns # ICNS格式图标包(macOS预设)
├── icon-512.png # 各种尺寸的图标...
├── icon-256.png
└── ...Context Discipline
上下文规范
Do not read generated icon images back into context. The script outputs file paths for all generated sizes. Ask the user to visually inspect the results. Icon sets produce many files across multiple sizes - reading them back would quickly exhaust the context window.
请勿将生成的图标图片重新读入上下文。 脚本会输出所有生成尺寸的文件路径。请让用户自行视觉检查结果。图标集包含多种尺寸的大量文件——将它们重新读入会迅速耗尽上下文窗口。
Troubleshooting
故障排除
| Issue | Solution |
|---|---|
| "GEMINI_API_KEY not set" | Export your API key: |
| "REPLICATE_API_TOKEN not set" | Export your token: |
| ICO not generated | Install ImageMagick: |
| ICNS not generated | Only works on macOS (requires iconutil) |
| Background not removed cleanly | Try a simpler prompt with solid background |
| Icon too complex | Simplify prompt, avoid "detailed" or "realistic" |
| 问题 | 解决方案 |
|---|---|
| "GEMINI_API_KEY未设置" | 导出你的API密钥: |
| "REPLICATE_API_TOKEN未设置" | 导出你的令牌: |
| 未生成ICO文件 | 安装ImageMagick: |
| 未生成ICNS文件 | 仅在macOS上可用(需要iconutil工具) |
| 背景移除不彻底 | 尝试使用更简单的提示词,指定纯色背景 |
| 图标过于复杂 | 简化提示词,避免使用“detailed”或“realistic”等描述 |