icon-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIcon Generator
图标生成器
Generate app icons in all required sizes from a single image.
从单张源图生成所有所需尺寸的应用图标。
Features
功能特性
- Multi-Platform: iOS, Android, Web, macOS, Windows
- Batch Generation: All sizes from one source
- Smart Scaling: Maintain quality at all sizes
- Format Support: PNG, ICO, ICNS
- Presets: Platform-specific size sets
- Rounding Options: Square or rounded corners
- 多平台支持:iOS、Android、Web、macOS、Windows
- 批量生成:从单张源图生成所有所需尺寸
- 智能缩放:在所有尺寸下保持画质
- 格式支持:PNG、ICO、ICNS
- 预设配置:针对不同平台的尺寸集合
- 圆角设置:支持方形或圆角样式
Quick Start
快速开始
python
from icon_generator import IconGenerator
gen = IconGenerator()python
from icon_generator import IconGenerator
gen = IconGenerator()Generate all iOS icons
Generate all iOS icons
gen.load("logo.png")
gen.generate_ios("ios_icons/")
gen.load("logo.png")
gen.generate_ios("ios_icons/")
Generate all favicon sizes
Generate all favicon sizes
gen.load("logo.png")
gen.generate_favicon("favicon/")
gen.load("logo.png")
gen.generate_favicon("favicon/")
Generate specific sizes
Generate specific sizes
gen.load("logo.png")
gen.generate_sizes([16, 32, 64, 128, 256, 512], "icons/")
undefinedgen.load("logo.png")
gen.generate_sizes([16, 32, 64, 128, 256, 512], "icons/")
undefinedCLI Usage
CLI 用法
bash
undefinedbash
undefinedGenerate iOS icons
Generate iOS icons
python icon_generator.py --input logo.png --preset ios --output-dir ios_icons/
python icon_generator.py --input logo.png --preset ios --output-dir ios_icons/
Generate Android icons
Generate Android icons
python icon_generator.py --input logo.png --preset android --output-dir android_icons/
python icon_generator.py --input logo.png --preset android --output-dir android_icons/
Generate favicons
Generate favicons
python icon_generator.py --input logo.png --preset favicon --output-dir favicon/
python icon_generator.py --input logo.png --preset favicon --output-dir favicon/
Custom sizes
Custom sizes
python icon_generator.py --input logo.png --sizes 16 32 64 128 256 -o icons/
python icon_generator.py --input logo.png --sizes 16 32 64 128 256 -o icons/
Generate all platforms
Generate all platforms
python icon_generator.py --input logo.png --preset all --output-dir app_icons/
undefinedpython icon_generator.py --input logo.png --preset all --output-dir app_icons/
undefinedAPI Reference
API 参考
IconGenerator Class
IconGenerator Class
python
class IconGenerator:
def __init__(self)
# Loading
def load(self, filepath: str) -> 'IconGenerator'
# Generation
def generate_ios(self, output_dir: str) -> List[str]
def generate_android(self, output_dir: str) -> List[str]
def generate_favicon(self, output_dir: str) -> List[str]
def generate_macos(self, output_dir: str) -> List[str]
def generate_windows(self, output_dir: str) -> List[str]
def generate_pwa(self, output_dir: str) -> List[str]
def generate_all(self, output_dir: str) -> Dict[str, List[str]]
# Custom
def generate_sizes(self, sizes: List[int], output_dir: str,
prefix: str = "icon") -> List[str]
def generate_single(self, size: int, output: str) -> str
# Options
def set_rounding(self, radius_percent: float) -> 'IconGenerator'
def set_padding(self, padding_percent: float) -> 'IconGenerator'
def set_background(self, color: Tuple) -> 'IconGenerator'python
class IconGenerator:
def __init__(self)
# Loading
def load(self, filepath: str) -> 'IconGenerator'
# Generation
def generate_ios(self, output_dir: str) -> List[str]
def generate_android(self, output_dir: str) -> List[str]
def generate_favicon(self, output_dir: str) -> List[str]
def generate_macos(self, output_dir: str) -> List[str]
def generate_windows(self, output_dir: str) -> List[str]
def generate_pwa(self, output_dir: str) -> List[str]
def generate_all(self, output_dir: str) -> Dict[str, List[str]]
# Custom
def generate_sizes(self, sizes: List[int], output_dir: str,
prefix: str = "icon") -> List[str]
def generate_single(self, size: int, output: str) -> str
# Options
def set_rounding(self, radius_percent: float) -> 'IconGenerator'
def set_padding(self, padding_percent: float) -> 'IconGenerator'
def set_background(self, color: Tuple) -> 'IconGenerator'Platform Sizes
平台尺寸规范
iOS (App Store)
iOS(App Store)
- 20x20, 29x29, 40x40, 60x60, 76x76, 83.5x83.5
- 1024x1024 (App Store)
- @2x and @3x variants
- 20x20, 29x29, 40x40, 60x60, 76x76, 83.5x83.5
- 1024x1024(App Store)
- @2x 和 @3x 变体
Android
Android
- mdpi: 48x48
- hdpi: 72x72
- xhdpi: 96x96
- xxhdpi: 144x144
- xxxhdpi: 192x192
- Play Store: 512x512
- mdpi: 48x48
- hdpi: 72x72
- xhdpi: 96x96
- xxhdpi: 144x144
- xxxhdpi: 192x192
- Play Store: 512x512
Favicon
Favicon
- 16x16, 32x32, 48x48
- 180x180 (Apple Touch)
- 192x192, 512x512 (PWA)
- 16x16, 32x32, 48x48
- 180x180(Apple Touch)
- 192x192, 512x512(PWA)
Windows
Windows
- 16x16, 32x32, 48x48
- 256x256 (ICO)
- 16x16, 32x32, 48x48
- 256x256(ICO)
Dependencies
依赖项
- pillow>=10.0.0
- pillow>=10.0.0