dreamega-ico-encoder
v1.0.0
Published
Generate .ico favicon files directly in the browser. Supports multi-size icons up to 1024px. No server needed.
Maintainers
Readme
dreamega-ico-encoder
Generate .ico favicon files directly in the browser. Supports multi-size icons up to 1024px. No server needed.
Extracted from Dreamega - an AI content creation platform.
Installation
npm install dreamega-ico-encoderUsage
import { generateIco, generatePreview, DEFAULT_SIZES } from "dreamega-ico-encoder";
// Load an image
const img = new Image();
img.src = "logo.png";
await new Promise((resolve) => (img.onload = resolve));
// Generate ICO with default sizes (16, 32, 48, 64, 128, 256, 512, 1024)
const icoBlob = await generateIco(img, [...DEFAULT_SIZES]);
// Generate ICO with custom sizes
const smallIco = await generateIco(img, [16, 32, 48]);
// Preview a specific size
const previewUrl = await generatePreview(img, 64);API
generateIco(source, sizes): Promise<Blob>
Generates a multi-size ICO file using PNG-in-ICO format (Windows Vista+).
source- AnHTMLImageElementorHTMLCanvasElementsizes- Array of pixel sizes to include
generatePreview(source, size): Promise<string>
Returns a data URL preview of the icon at a specific size.
DEFAULT_SIZES
Default icon sizes: [16, 32, 48, 64, 128, 256, 512, 1024]
Features
- Pure browser implementation, no server required
- PNG-in-ICO format for high quality at all sizes
- High-quality image resizing with bicubic interpolation
- Supports sizes from 16px to 1024px
- Zero dependencies
License
MIT - see LICENSE
