imgico (Wasm)
High-performance image to ICO/SVG converter for the browser, built with Rust and WebAssembly.
This is the WebAssembly port of the imgico library, allowing client-side image conversion without server dependencies.
Features
- Client-side Conversion: Convert images directly in the browser.
- Fast & Efficient: Powered by Rust and WebAssembly.
- Small Footprint: Optimized for size (~430KB).
- Supports:
- Image to ICO (multiple sizes)
- Image to SVG (embedded PNG)
Build
To build the project from source:
- Install Rust: https://rustup.rs/
- Install wasm-pack:
- Build:
This will generate a pkg directory which can be imported into your web application.
Usage
Initialization
You must initialize the Wasm module before using the conversion functions.
import init from './pkg/imgico.js';
;
CLI Usage
You can also use imgico as a command-line tool.
Installation
Usage
Options:
-f, --format <type>: Output format: 'ico' or 'svg' (default: ico)-h, --help: Show help message
Example:
API
imgico(input, sizes?)
input:Uint8Array- The input image data.sizes:Uint32Array | number[](optional) - List of sizes to include in the ICO. Default:[16, 32, 48, 64, 128, 256].
Returns: Uint8Array (The generated ICO file data).
imgsvg(input, size?)
input:Uint8Array- The input image data.size:number(optional) - The target width/height for the embedded image. If omitted, uses original size.
Returns: Uint8Array (The generated SVG file data as bytes).
License
ISC