generate-icon

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Generate 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
undefined
bash
undefined

Favicon 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
undefined
bun run icon "settings gear" --preset ui-icons --output ./icons/ui
undefined

Presets

预设配置

PresetDescriptionSizesBundle
apple-app-icon
iOS/iPadOS App Store18 sizes (1024-20px)No
android-app-icon
Google Play + adaptive layers11 sizes + foregroundNo
favicon
Browser tab icons8 sizes + ICOYes (.ico)
pwa
Progressive Web App11 sizes + maskableNo
macos-icns
macOS desktop10 sizesYes (.icns)
windows-ico
Windows desktop7 sizesYes (.ico)
ui-icons
In-app icons9 sizes (512-16px)No
预设配置说明尺寸打包
apple-app-icon
iOS/iPadOS App Store图标18种尺寸(1024-20px)
android-app-icon
Google Play图标 + 自适应图层11种尺寸 + 前景层
favicon
浏览器标签页图标8种尺寸 + ICO格式是(.ico)
pwa
渐进式Web应用图标11种尺寸 + 可遮罩图标
macos-icns
macOS桌面应用图标10种尺寸是(.icns)
windows-ico
Windows桌面应用图标7种尺寸是(.ico)
ui-icons
应用内UI图标9种尺寸(512-16px)

Pipeline

处理流程

  1. Generate - Creates master icon at high resolution via Gemini
  2. Remove Background - Uses Replicate rembg for clean edges
  3. Crop & Center - Trims whitespace, centers on square canvas with 5% padding
  4. Resize - Exports all preset sizes with lanczos3 interpolation
  5. Bundle - Creates ICO/ICNS bundles where needed
  1. 生成 - 通过Gemini生成高分辨率的主图标
  2. 移除背景 - 使用Replicate的rembg工具实现边缘清晰的背景移除
  3. 裁剪与居中 - 去除空白区域,在方形画布上居中图标并保留5%内边距
  4. 调整尺寸 - 使用lanczos3插值算法导出所有预设尺寸的图标
  5. 打包 - 按需创建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 presets
bun 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 ./icons
bash
bun run icon "clean app icon version" --preset pwa --input ./existing-logo.png --output ./icons

Using an existing master

使用已有主图标

bash
bun run icon "" --preset ui-icons --master-image ./my-icon.png --skip-generate --output ./icons
bash
bun run icon "" --preset ui-icons --master-image ./my-icon.png --skip-generate --output ./icons

iOS with custom background color

带自定义背景色的iOS图标

bash
bun run icon "weather app sun" --preset apple-app-icon --bg-color "#0066CC" --output ./icons/ios
bash
bun run icon "weather app sun" --preset apple-app-icon --bg-color "#0066CC" --output ./icons/ios

Icon 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

环境变量

VariableRequiredDescription
GEMINI_API_KEY
YesGoogle AI Studio API key
REPLICATE_API_TOKEN
YesReplicate API token for background removal
变量是否必填说明
GEMINI_API_KEY
Google AI Studio的API密钥
REPLICATE_API_TOKEN
用于背景移除的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

故障排除

IssueSolution
"GEMINI_API_KEY not set"Export your API key:
export GEMINI_API_KEY=your-key
"REPLICATE_API_TOKEN not set"Export your token:
export REPLICATE_API_TOKEN=your-token
ICO not generatedInstall ImageMagick:
brew install imagemagick
ICNS not generatedOnly works on macOS (requires iconutil)
Background not removed cleanlyTry a simpler prompt with solid background
Icon too complexSimplify prompt, avoid "detailed" or "realistic"
问题解决方案
"GEMINI_API_KEY未设置"导出你的API密钥:
export GEMINI_API_KEY=your-key
"REPLICATE_API_TOKEN未设置"导出你的令牌:
export REPLICATE_API_TOKEN=your-token
未生成ICO文件安装ImageMagick:
brew install imagemagick
未生成ICNS文件仅在macOS上可用(需要iconutil工具)
背景移除不彻底尝试使用更简单的提示词,指定纯色背景
图标过于复杂简化提示词,避免使用“detailed”或“realistic”等描述