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

@toolsycc/image-convert

v0.1.5

Published

A utility package for converting image formats.

Downloads

29

Readme

@toolsycc/image-convert

A lightweight and focused utility to convert images to ICO format.
✅ Works with both TypeScript and JavaScript (ESM & CommonJS).

Features

  • Image to ICO conversion (supports PNG, JPEG, etc.)
  • Support for:
    • Input from Buffer
    • EXIF-based auto-orientation
    • Metadata stripping to reduce file size
    • Automatic multiple size generation (16x16 to 256x256)
    • Custom size selection
  • Minimalist and no unnecessary dependencies
  • Windows icon compatible output
  • Designed for Node.js environments only (sharp-based).

Installation

pnpm add @toolsycc/image-convert

Or with npm:

npm install @toolsycc/image-convert

Usage Examples

🟦 TypeScript

⚠️ This module relies on sharp and must be used server-side only. Import it in Next.js API routes or server functions.

import { convertToIco } from '@toolsycc/image-convert';
import { promises as fs } from 'fs';

// Basic ICO conversion from file
async function convertFileToIco() {
  // Read image file into a Buffer
  const imageBuffer = await fs.readFile('input.png');
  
  // Convert to ICO buffer
  const icoBuffer = await convertToIco(imageBuffer);
  
  // Save the ICO buffer to a file
  await fs.writeFile('output.ico', icoBuffer);
  
  console.log('Conversion completed successfully');
}

// With custom options
async function convertWithOptions() {
  const imageBuffer = await fs.readFile('input.png');
  
  const icoBuffer = await convertToIco(imageBuffer, {
    autoOrient: true,    // Auto-orient based on EXIF
    stripMetadata: true, // Remove metadata
    sizes: [16, 32, 64] // Custom sizes
  });
  
  await fs.writeFile('output.ico', icoBuffer);
}

// Handle errors
try {
  await convertFileToIco();
} catch (error) {
  console.error('Conversion failed:', error);
}

🟨 JavaScript (CommonJS)

const { convertToIco } = require('@toolsycc/image-convert');
const fs = require('fs').promises;

// Simple conversion
async function convert() {
  const buffer = await fs.readFile('input.png');
  const icoBuffer = await convertToIco(buffer);
  await fs.writeFile('output.ico', icoBuffer);
}

convert()
  .then(() => console.log('Conversion completed'))
  .catch(console.error);

🟩 JavaScript (ESM)

import { convertToIco } from '@toolsycc/image-convert';
import { promises as fs } from 'fs';

// With error handling
try {
  const imageBuffer = await fs.readFile('input.png');
  const icoBuffer = await convertToIco(imageBuffer);
  await fs.writeFile('output.ico', icoBuffer);
  console.log('Conversion successful');
} catch (error) {
  console.error('Conversion error:', error);
}

IcoOptions

interface IcoOptions {
  /**
   * Auto-orient based on EXIF data
   * @default true
   */
  autoOrient?: boolean;
  
  /**
   * Remove metadata (EXIF, profiles, comments)
   * @default true
   */
  stripMetadata?: boolean;
  
  /**
   * Sizes to generate for the ICO file (in pixels)
   * Must be between 16 and 256 pixels
   * @default [16, 24, 32, 48, 64, 96, 128, 192, 256]
   */
  sizes?: number[];
}

Error Handling

The function will throw errors in the following cases:

  • Input is not a Buffer
  • Image size is less than 16px or greater than 256px
  • Invalid image format
  • Processing errors

Motivation

This package was designed to provide a simple and efficient way to convert images to ICO format, working seamlessly in both Node.js and browser environments. It's particularly useful for developers creating Windows applications or websites requiring high-quality icons.

Author

Made by @Sebog33
Follow Toolsy for more tiny dev-focused utilities.

License

MIT