Skip to content

ciptacode/image2ico

Repository files navigation

@ciptacode/image2ico

Image to ICO converter using Rust and WebAssembly.

Installation

npm install @ciptacode/image2ico

Usage

Web (Vanilla JS)

import init, { convert_to_ico } from "@ciptacode/image2ico";

async function run() {
    await init();

    const response = await fetch('image.png');
    const buffer = await response.arrayBuffer();
    const uint8Array = new Uint8Array(buffer);

    try {
        const icoData = convert_to_ico(uint8Array);
        const blob = new Blob([icoData], { type: 'image/x-icon' });
        const url = URL.createObjectURL(blob);
        
        const img = document.createElement('img');
        img.src = url;
        document.body.appendChild(img);
    } catch (error) {
        console.error("Conversion failed:", error);
    }
}

run();

React / Bundlers

If you are using a bundler like Webpack or Vite, you might need to use the build:bundler target or configure your bundler to handle WASM.

Build

# Build for web
npm run build

# Build for bundlers
npm run build:bundler

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors