npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

img2ico

v1.3.1

Published

A tool for converting image to ICO format.

Downloads

129

Readme

img2ico

License npm version NPM Downloads Build Status

English | 简体中文

A tool for converting image to ICO format.

Features

  • Convert PNG, JPEG, BMP, and WebP image formats to ICO.
  • Uses WASM for faster processing. If WASM running fails, it falls back to a pure JavaScript implementation.
  • Supports custom ICO sizes.
  • Available as a CLI tool, Node.js module, and for use in browsers.

Usage

CLI

Convert images to ICO from your command line.

npx img2ico <inputFile> [outputFile] [-s, --sizes <sizes>]
  • <inputFile>: Path to the input image file.
  • [outputFile]: Optional path for the output .ico file. If omitted, it defaults to <inputFile>.ico.
  • -s, --sizes <sizes>: Comma-separated list of desired ICO sizes (e.g., 16,32,48). Default sizes are 16,24,32,48,64,96,128,256.

Examples:

npx img2ico icon.png
npx img2ico icon.png icon.ico -s "16,32,48"

Web UI

Access the web interface for easy conversion: https://nini22p.github.io/img2ico/

The web tool provides a wide range of size options, including 16, 20, 24, 30, 32, 36, 40, 48, 60, 64, 72, 80, 96, 128, 256, 512, 1024.

Node.js

Use img2ico in your Node.js project.

npm install img2ico
import img2ico from 'img2ico';
import fs from 'fs/promises';

async function convertImage() {
  const imageBuffer = await fs.readFile('icon.png');

  // By default, img2ico generates icons with the following sizes:
  // [16, 24, 32, 48, 64, 96, 128, 256].
  const icoResult = await img2ico(imageBuffer);

  // To specify a custom set of sizes, pass an options object as the
  // second argument. For example, to generate only 16px, 32px, and 48px icons:
  // const icoResult = await img2ico(imageBuffer, { sizes: [16, 32, 48] });

  // Get the ICO data as a Buffer
  const icoBuffer = icoResult.toBuffer();
  await fs.writeFile('icon.ico', icoBuffer);
  console.log('ICO created successfully!');
}

convertImage();

Browser

Use img2ico in your web project.

npm install img2ico
import img2ico from 'img2ico';

async function convertImageInBrowser(file: File) {
  const arrayBuffer = await file.arrayBuffer();

  // By default, img2ico generates icons with the following sizes:
  // [16, 24, 32, 48, 64, 96, 128, 256].
  const icoResult = await img2ico(arrayBuffer);

  // To specify a custom set of sizes, pass an options object as the
  // second argument. For example, to generate only 16px, 32px, and 48px icons:
  // const icoResult = await img2ico(arrayBuffer, { sizes: [16, 32, 48] });

  // Get the ICO data as a Data URL string (e.g., "data:image/x-icon;base64,...").
  const icoDataUrl = icoResult.toDataUrl();

  // Example: Create a download link
  const a = document.createElement('a');
  a.href = icoDataUrl;
  a.download = 'icon.ico'; // You can set the desired filename here
  document.body.appendChild(a);
  a.click();
  document.body.removeChild(a);

  // Example: Display the ICO image directly in an <img> tag
  const imgElement = document.createElement('img');
  imgElement.src = icoDataUrl;
  imgElement.alt = 'Generated ICO';
  document.body.appendChild(imgElement);
}

// Example usage with a file input:
document.getElementById('fileInput').addEventListener('change', async (event) => {
  const file = (event.target as HTMLInputElement).files[0];
  if (file) {
    await convertImageInBrowser(file);
  }
});

License

MIT