imgico
High-performance image to ICO/SVG converter built with Rust.
Features:
- 🦀 Pure Rust - Fast and memory-safe
- 🌐 WebAssembly Support - Run in the browser
- 🖼️ Multiple Formats - ICO (multi-size) and SVG output
- 🎯 Simple API - Easy to use in both Rust and JavaScript
- ⚡ High Performance - Optimized for speed and size
Installation
As a Rust Library
If you wanna specific version, add to your Cargo.toml:
[]
= "0.1.3"
As a CLI Tool
For WebAssembly
Build from source:
# Install wasm-pack
# Build
Usage
Rust Library
use ;
use fs;
CLI Usage
Convert image to ICO format:
Convert image to SVG format:
This creates a directory with timestamped name containing multiple sizes (16, 32, 48, 64, 128, 256).
WebAssembly (Browser)
import init from './pkg/imgico.js';
;
API Reference
Rust
imgico_core(input: &[u8], sizes: Option<Vec<u32>>) -> Result<Vec<u8>, String>
Convert an image to ICO format.
Parameters:
input- Input image data (PNG, JPEG, WebP, etc.)sizes- Optional vector of icon sizes. Default:[16, 32, 48, 64, 128, 256]
Returns: ICO file data as bytes
Example:
let ico = imgico_core?;
imgsvg_core(input: &[u8], size: Option<u32>) -> Result<Vec<u8>, String>
Convert an image to SVG format with embedded PNG.
Parameters:
input- Input image datasize- Optional target width/height. IfNone, uses original size
Returns: SVG file data as bytes
Example:
let svg = imgsvg_core?;
WebAssembly (JavaScript)
imgico(input: Uint8Array, sizes?: Uint32Array) -> Uint8Array
Convert an image to ICO format.
Parameters:
input- Input image data asUint8Arraysizes- Optional array of icon sizes. Default:[16, 32, 48, 64, 128, 256]
Returns: ICO file data as Uint8Array
Example:
const icoData = ;
imgsvg(input: Uint8Array, size?: number) -> Uint8Array
Convert an image to SVG format.
Parameters:
input- Input image data asUint8Arraysize- Optional target width/height
Returns: SVG file data as Uint8Array
Example:
const svgData = ;
const svgString = .;
Supported Input Formats
- PNG
- JPEG
- WebP
- GIF
- BMP
- And more (via the
imagecrate)
Building from Source
# Clone the repository
# Build Rust library/CLI
# Build WebAssembly
# Run tests
Performance
The library is optimized for both speed and size:
- Uses Lanczos3 filtering for high-quality resizing
- WebAssembly build is ~430KB (optimized)
- Fast processing with minimal memory overhead
License
MIT OR Apache-2.0