A cross-platform CLI tool for generating icons in various formats from a single source image. This tool creates icons for Windows (ICO), macOS (ICNS), Linux (PNG), Android, iOS, and Tauri platforms.
- Multi-platform icon generation: Generates icons for Windows, macOS, Linux, Android, iOS, and Tauri
- Platform-specific directories: Each platform gets its own dedicated subdirectory for easy drag-and-drop
- Multiple formats: ICO, ICNS, and PNG formats with appropriate sizes
- Customizable sizes: Generate custom PNG sizes as needed
- Mobile platform support: Automatically generates Android and iOS app icons
- Tauri support: Dedicated
tauri-desktopfolder for Tauri projects - Background color support: Add background colors for iOS icons
- Development badge support: Add a "DEV" badge overlay to icons for development builds
- Apple Asset Catalog support: Automatic generation of
Contents.jsonfor iOS and macOS - Cross-platform: Runs on Windows, macOS, and Linux
The repo also ships an independent image_gen binary that generates an image
from a text prompt using a provider-agnostic backend. Currently it supports
OpenAI's gpt-image-2 model. The output is a single image file that you can
feed straight into icon_gen to produce icons.
# 1. Generate a source image from a prompt
image_gen --prompt "a cute otter holding a glass bottle, flat icon" \
--output otter.png
# 2. Pipe it into icon_gen to produce all platform icons
icon_gen otter.png| Flag | Env var | Default |
|---|---|---|
--provider |
— | openai |
--model, -m |
— | gpt-image-2 (provider default) |
--api-key |
OPENAI_API_KEY |
(required) |
--base-url |
OPENAI_BASE_URL |
https://api.openai.com/v1 |
--size |
— | 1024x1024 |
--quality |
— | auto |
--format |
— | png |
--background |
— | opaque |
Both --api-key and --base-url can be supplied as flags or via env vars.
This lets you point at any OpenAI-compatible proxy (LiteLLM, OpenRouter,
self-hosted gateway) without changing the binary.
OPENAI_API_KEY=sk-...
OPENAI_BASE_URL=https://your-proxy.example.com/v1
image_gen --prompt "a minimal mountain logo" --output logo.png
The image_gen module is exposed for embedders:
use icon_gen::image_gen::{
generate_image, GenerateRequest, ImageSize, OutputFormat, ProviderConfig, Quality,
};
let cfg = ProviderConfig::new("sk-...", "https://api.openai.com/v1", "gpt-image-2");
let req = GenerateRequest::new("a minimal mountain logo")
.with_size(ImageSize::new(1024, 1024))
.with_quality(Quality::High)
.with_output_format(OutputFormat::Png);
let image = generate_image("openai", &cfg, &req)?;
std::fs::write("logo.png", image.bytes)?;Adding a new provider (Stability, Replicate, local) is a single file under
image_gen::providers plus one match arm in create_generator. The shape
is designed to compose with icon_gen in a future pipeline command.
- Install Rust from rustup.rs
- Clone this repository:
git clone <repository-url> cd icon_generator
- Build and install all binaries (
icon_gen+image_gen+ utilities):cargo installall # alias defined in .cargo/config.toml # or equivalently: cargo install --path . --bins
Note:
cargo install --path .(without--bins) only installs the package's primary binary (icon_gen). To also installimage_gen, you must pass--bins(or use theinstallallalias). This is standard Cargo behavior.
Check the Releases page for pre-built binaries.
icon_gen input-image.pngThis will generate all icon formats in a directory named icon_generator-input-image/ (based on the source filename).
# Specify output directory
icon_gen input-image.png -o /path/to/output
# Generate only Tauri desktop icons (recommended for Tauri projects)
icon_gen input-image.png --tauri-desktop
# Generate custom PNG sizes only
icon_gen input-image.png -p 16,32,64,128,256
# Generate only desktop platform icons (Windows, macOS, Linux)
icon_gen input-image.png --desktop-only
# Generate only mobile platform icons (Android, iOS)
icon_gen input-image.png --mobile-only
# Set iOS background color
icon_gen input-image.png --ios-color "#FF5733"
# Add development/debug badge to all generated icons
icon_gen input-image.png --dev-mode
# Add development badge with specific bug type
icon_gen input-image.png --dev-mode --dev-bug spider
# Generate icons for specific platforms
icon_gen input-image.png --windows --macos
icon_gen input-image.png --android --ios
icon_gen input-image.png --linux -p 16,32,64,128,256Generate various icons for all major platforms
Usage: icon_gen [OPTIONS] <INPUT>
Arguments:
<INPUT> Path to the source icon (squared PNG file with transparency)
Options:
-o, --output <DIR> Output directory (default: icon_generator-{source-name})
-p, --png <SIZES> Custom PNG icon sizes to generate. When set, only these sizes are generated
--desktop-only Generate only desktop platform icons (Windows, macOS, Linux)
--mobile-only Generate only mobile platform icons (Android, iOS)
--tauri-desktop Generate Tauri desktop icons (tauri-desktop folder with icons for src-tauri/icons)
--windows Generate icons for Windows platform
--macos Generate icons for macOS platform
--linux Generate icons for Linux/Desktop platform
--android Generate icons for Android platform
--ios Generate icons for iOS platform
--ios-color <IOS_COLOR> The background color for iOS icons (CSS color format) [default: #ffffff]
--dev-mode Add a development/debug badge to all generated icons
--dev-bug <BUG> Bug type to use for dev badge (cockroach, ladybug, moth, spider, caterpillar) - only effective with --dev-mode [default: moth]
-h, --help Print help
Sizes, filenames, and format requirements are declared in
config/icon-specs.toml and embedded into the
binary at compile time. Update that file (no Rust changes needed) when a
platform revises its icon spec.
- Directory:
windows/ - File:
icon.ico - Sizes: 16×16, 24×24, 32×32, 48×48, 64×64, 128×128, 256×256
- Format: Multi-layer ICO file with PNG compression for 256×256
- Directory:
macos/ - Files:
icon.icns,Contents.json - Sizes: 16×16, 32×32, 128×128, 256×256, 512×512, 1024×1024 (including @2x variants)
- Format: Apple ICNS format with Apple's standard 10-slot set
(
is32,il32,ic07–ic14)
- Directory:
linux/ - Files:
16x16.png,24x24.png,32x32.png,48x48.png,64x64.png,128x128.png,256x256.png,icon.png(512×512) - Format: PNG with transparency
- Directory:
tauri-desktop/ - Files:
32x32.png,128x128.png,128x128@2x.png,icon.ico,icon.icns - Purpose: Ready-to-use icons for Tauri's
src-tauri/iconsfolder
- Directory:
android/mipmap-*/ - Files:
ic_launcher.pngin each density folder - Densities: mdpi (48×48), hdpi (72×72), xhdpi (96×96), xxhdpi (144×144), xxxhdpi (192×192)
- Directory:
ios/ - Files: Various
AppIcon-*files for different iOS icon requirements - Sizes: 20×20 to 1024×1024 with @1x, @2x, @3x variants
- Background: Applies specified background color (iOS requires opaque icons)
- Asset Catalog: Automatic generation of
Contents.jsonfor Xcode compatibility
All sizes, filenames, and format requirements live in
config/icon-specs.toml. Each platform section
is keyed by its platforms.<name> and contains the relevant sizes,
encodings, and metadata. The file is embedded into the binary at compile
time via include_str!, so updates still require a rebuild — but no Rust
changes are needed when, say, Apple adds a new AppIcon slot or Linux
adds a new recommended density.
Sources referenced in the file's header comments:
| Platform | Spec source |
|---|---|
| Windows ICO | Microsoft Win32 design guide |
| macOS ICNS | Apple Icon Image format |
| Linux PNG | freedesktop.org icon-theme spec |
| iOS AppIcon | Apple Human Interface Guidelines |
| Android | Android screen densities and adaptive icons |
| Tauri | Tauri updater guide |
The --dev-mode flag (alias: --debug) adds a visual development badge overlay to all generated icons. This feature is useful for:
- Development builds: Easily distinguish development icons from production icons
- Testing environments: Visual indicator for QA and staging builds
- Beta releases: Mark pre-release versions with a clear visual indicator
The badge uses charming bug images (moth, cockroach, ladybug, spider, or caterpillar) that are automatically scaled and centered on each icon. The default bug is a moth with random rotation for visual variety.
moth(default): Classic moth with random rotation (0-360°)cockroach: Cockroach with fixed orientationladybug: Ladybug with fixed orientationspider: Spider with fixed orientationcaterpillar: Caterpillar with fixed orientation
# Use default moth with random rotation
icon_gen source.png --dev-mode
# Specify different bug types
icon_gen source.png --dev-mode --dev-bug spider
icon_gen source.png --dev-mode --dev-bug ladybug
icon_gen source.png --dev-mode --dev-bug cockroach
icon_gen source.png --dev-mode --dev-bug caterpillar
# Combine with other options
icon_gen source.png --dev-mode --dev-bug moth --mobile-only- Smart Scaling: Bugs automatically scale to 1/4 of the icon size
- Perfect Centering: Bugs are precisely centered on each icon
- Random Rotation: Moth gets random rotation for visual variety
- Cross-Platform: Works across all supported formats (ICO, ICNS, PNG, Android, iOS)
- Alpha Blending: Seamless overlay with proper transparency handling
This tool automatically generates Apple's Contents.json files for both iOS and macOS platforms, making the generated icons ready for use in Xcode projects without any additional configuration.
- Purpose: Defines metadata for iOS app icons including sizes, scales, idioms, and roles
- Compatibility: Works with all iOS devices (iPhone, iPad, and iOS Marketing)
- Roles: Includes proper roles for notification center, spotlight, app launcher, and companion settings
- No Xcode Post-processing: Icons are immediately ready for use in iOS projects
- Purpose: Defines metadata for macOS app icons with proper scaling and size information
- Compatibility: Supports all macOS icon sizes from 16×16 to 1024×1024 with @1x and @2x variants
- Integration: Works seamlessly with macOS app bundles and Xcode projects
- No Xcode Post-processing: Icons are immediately ready for use in macOS projects
The generated Contents.json files follow Apple's official Asset Catalog Format Reference, ensuring full compatibility with Xcode and the Apple development ecosystem.
- Format: PNG (other formats supported by the
imagecrate may work) - Size: Must be square (width = height)
- Recommended: 1024×1024 or larger for best quality
- Transparency: Supported (except iOS icons which get background color applied)
icon_gen app-icon-1024.pngicon_gen app-icon.png --desktop-onlyicon_gen favicon-source.png -p 16,32,48 -o favicon-outputicon_gen transparent-icon.png --ios-color "#2196F3"icon_gen app-icon.png --mobile-only# Generate only Windows icons
icon_gen app-icon.png --windows
# Generate only mobile app icons (alternative approach)
icon_gen app-icon.png --android --ios
# Generate desktop icons only (alternative approach)
icon_gen app-icon.png --windows --macos --linux
# Generate Linux icons with custom sizes
icon_gen app-icon.png --linux -p 16,24,32,48,64,128,256# Generate only Tauri desktop icons (recommended for Tauri)
icon_gen app-icon.png --tauri-desktop
# The tauri-desktop folder can be directly copied to src-tauri/icons
# Simply drag and drop the contents into your Tauri project# Add a bug overlay to all generated icons for development builds
icon_gen app-icon.png --dev-mode
# Specify which bug to use
icon_gen app-icon.png --dev-mode --dev-bug spider
icon_gen app-icon.png --dev-mode --dev-bug caterpillar
# Combine with other options
icon_gen app-icon.png --dev-mode --mobile-only
icon_gen app-icon.png --dev-mode --ios-color "#2196F3"
icon_gen app-icon.png --dev-mode --dev-bug ladybug --android --iosWhen generating all formats, the output directory structure will be:
{output}/ # Default: icon_generator-{source-name}/
├── windows/ # Windows icons
│ └── icon.ico
├── macos/ # macOS icons
│ ├── icon.icns
│ └── Contents.json # macOS Asset Catalog metadata
├── linux/ # Linux desktop icons
│ ├── 32x32.png
│ ├── 64x64.png
│ ├── 128x128.png
│ ├── 256x256.png
│ └── icon.png # 512x512
├── tauri-desktop/ # Tauri desktop icons
│ ├── 32x32.png
│ ├── 128x128.png
│ ├── 128x128@2x.png
│ ├── icon.ico
│ └── icon.icns
├── android/ # Android icons
│ ├── mipmap-mdpi/
│ │ └── ic_launcher.png
│ ├── mipmap-hdpi/
│ │ └── ic_launcher.png
│ └── ...
└── ios/ # iOS icons
├── Contents.json # iOS Asset Catalog metadata
├── AppIcon-20x20@1x.png
├── AppIcon-20x20@2x.png
├── AppIcon-29x29@1x.png
├── AppIcon-29x29@2x.png
├── AppIcon-40x40@1x.png
├── AppIcon-40x40@2x.png
├── AppIcon-60x60@2x.png
├── AppIcon-60x60@3x.png
├── AppIcon-76x76@1x.png
├── AppIcon-76x76@2x.png
├── AppIcon-83x83@2x.png
└── AppIcon-1024x1024.png
- Rust 1.70+ (install from rustup.rs)
- System dependencies for image processing (usually included)
# Debug build
cargo build
# Release build (optimized)
cargo build --release
# Run tests
cargo test
# Install locally
cargo install --path .Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the Tauri CLI icon generation functionality
- Built with the Rust ecosystem's excellent image processing libraries