@ciptacode/image2ico
v0.1.0
Published
Image to ICO converter using Rust and WebAssembly
Maintainers
Readme
@ciptacode/image2ico
Image to ICO converter using Rust and WebAssembly.
Installation
npm install @ciptacode/image2icoUsage
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 options = { width: 32, height: 32 }; // Optional resize
const icoData = convert_to_ico(uint8Array, options);
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:bundlerLicense
MIT
