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

icns-gen

v1.1.0

Published

[![npm version](https://img.shields.io/npm/v/icns-gen.svg)](https://www.npmjs.com/package/icns-gen) [![Build Status](https://github.com/whyun-pages/icns-gen/actions/workflows/ci.yml/badge.svg)](https://github.com/whyun-pages/icns-gen/actions/workflows/ci.

Downloads

4

Readme

icns-gen

npm version Build Status Coverage Status License: MIT npm downloads TypeScript Node.js Version

A Node.js library for generating Apple ICNS (Icon Container) files from PNG images.

Installation

npm install icns-gen
# or
pnpm install icns-gen
# or
yarn add icns-gen

Usage

Basic Usage

import { gen, AssetSize } from 'icns-gen';

const assets = [
    {
        size: AssetSize.S32,  // 32x32
        path: './icon-32.png'
    },
    {
        size: AssetSize.S64,  // 64x64
        path: './icon-64.png'
    },
    {
        size: AssetSize.S128, // 128x128
        path: './icon-128.png'
    },
    {
        size: AssetSize.S256, // 256x256
        path: './icon-256.png'
    },
    {
        size: AssetSize.S512, // 512x512
        path: './icon-512.png'
    },
    {
        size: AssetSize.S1024, // 1024x1024
        path: './icon-1024.png'
    }
];

await gen(assets, './output/icon.icns');

Using Buffers

You can also provide image data as buffers instead of file paths:

import { readFileSync } from 'fs';
import { gen, AssetSize } from 'icns-gen';

const assets = [
    {
        size: AssetSize.S32,
        buffer: readFileSync('./icon-32.png')
    },
    {
        size: AssetSize.S64,
        buffer: readFileSync('./icon-64.png')
    }
    // ... more sizes
];

await gen(assets, './output/icon.icns');

CommonJS Usage

const { gen, AssetSize } = require('icns-gen');

// Same usage as above

API

gen(assets: Asset[], output: string): Promise<void>

Generates an ICNS file from the provided assets.

Parameters

  • assets: Array of asset objects
    • size: One of the supported sizes (see AssetSize enum)
    • path?: Path to the PNG file (either path or buffer must be provided)
    • buffer?: Buffer containing PNG data (either path or buffer must be provided)
  • output: Output path for the generated ICNS file

Throws

  • GenError with code ASSET_PATH_OR_BUFFER_MUST_BE_SET: When neither path nor buffer is provided
  • GenError with code ASSET_SIZE_NOT_SUPPORTED: When an unsupported size is provided
  • GenError with code ASSET_EMPTY: When the provided file or buffer is empty

AssetSize

Enum of supported icon sizes:

enum AssetSize {
    S32 = 32,    // 32x32 pixels
    S64 = 64,    // 64x64 pixels
    S128 = 128,  // 128x128 pixels
    S256 = 256,  // 256x256 pixels
    S512 = 512,  // 512x512 pixels
    S1024 = 1024 // 1024x1024 pixels
}

Supported Icon Types

The library generates the following icon types based on the provided sizes:

| Size | Icon Types | Description | |------|------------|-------------| | 32 | icp5 | 32x32 PNG format | | 64 | icp6, ic11 | 64x64 PNG format (ic11 is 32x32@2x Retina) | | 128 | ic07, ic12 | 128x128 PNG format (ic12 is 64x64@2x Retina) | | 256 | ic08 | 256x256 PNG format | | 512 | ic09, ic13 | 512x512 PNG format (ic13 is 256x256@2x Retina) | | 1024 | ic10, ic14 | 1024x1024 PNG format (ic14 is 512x512@2x Retina) |

Requirements

  • Node.js >= 14
  • PNG format images with the exact dimensions specified

Example

import { gen, AssetSize, GenError, GenErrorCode } from 'icns-gen';

try {
    await gen([
        { size: AssetSize.S32, path: './icons/icon-32.png' },
        { size: AssetSize.S128, path: './icons/icon-128.png' },
        { size: AssetSize.S512, path: './icons/icon-512.png' },
        { size: AssetSize.S1024, path: './icons/icon-1024.png' }
    ], './app.icns');
    
    console.log('ICNS file generated successfully!');
} catch (error) {
    if (error instanceof GenError) {
        switch (error.code) {
            case GenErrorCode.ASSET_PATH_OR_BUFFER_MUST_BE_SET:
                console.error('Please provide either a path or buffer for each asset');
                break;
            case GenErrorCode.ASSET_SIZE_NOT_SUPPORTED:
                console.error('One of the provided sizes is not supported');
                break;
            case GenErrorCode.ASSET_EMPTY:
                console.error('One of the provided files is empty');
                break;
        }
    } else {
        console.error('Unexpected error:', error);
    }
}

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development

# Install dependencies
pnpm install

# Build
pnpm build

# Run tests
pnpm test

# Lint
pnpm lint

TODO

  • [] Command line tool