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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fiahfy/icns

v0.0.7

Published

Apple Icon Image format parser and builder

Downloads

1,540

Readme

icns

badge

Apple Icon Image format parser and builder.

Installation

npm install @fiahfy/icns

Usage

Parsing

import fs from 'fs'
import { Icns } from '@fiahfy/icns'

const buf = fs.readFileSync('icon.icns')
const icns = Icns.from(buf)
const imagesAsBuffers = icns.images.map((icon) => icon.image)

Note that the images may be encoded in different file formats, in accordance with Apple's icon type specifications.

Building

import fs from 'fs'
import { Icns, IcnsImage } from '@fiahfy/icns'

const icns = new Icns()
let buf, image

buf = fs.readFileSync('512x512.png')
image = IcnsImage.fromPNG(buf, 'ic09')
icns.append(image)

buf = fs.readFileSync('1024x1024.png')
image = IcnsImage.fromPNG(buf, 'ic10')
icns.append(image)

/* Some other PNG files */

fs.writeFileSync('icon.icns', icns.data)

API

Class: Icns

static from(buffer)

Create ICNS from the icon buffer.

buffer

Type: Buffer

The ICNS icon buffer.

append(image)

Adds ICNS image at the end.

image

Type: IcnsImage

The ICNS Image to append.

insert(image, index)

Inserts ICNS image at the specified position.

image

Type: IcnsImage

The ICNS Image to insert.

index

Type: number

The position at which to insert the ICNS Image.

remove(index)

Removes ICNS image at the specified position.

index

Type: number

The position of the ICNS Image to remove.

fileHeader

Type: IcnsFileHeader

Return the file header on the ICNS.

images

Type: IcnsImage[]

Return the ICNS images on the ICNS.

data

Type: Buffer

Return the ICNS buffer.

Class: IcnsImage

static from(buffer)

Create ICNS image from the buffer.

buffer

Type: Buffer

The ICNS image buffer.

static fromPNG(buffer, osType)

Create ICNS Image from the PNG image buffer.

buffer

Type: Buffer

The PNG image buffer.

osType

Type: OSType

The icon OSType.

Class: IcnsFileHeader

static from(buffer)

Create ICNS file header from the buffer.

buffer

Type: Buffer

The ICNS file header buffer.

Specifications

Supported OSTypes

| OSType | OS Version | Size | Description | | ------ | ---------- | ---- | --------------------------------------------------------------------- | | is32 | 8.5 | 16 | 16×16 24-bit icon | | il32 | 8.5 | 32 | 32x32 24-bit icon | | ih32 | 8.5 | 48 | 48×48 24-bit icon | | it32 | 10.0 | 128 | 128x128 24-bit icon | | s8mk | 8.5 | 16 | 16x16 8-bit mask | | l8mk | 8.5 | 32 | 32×32 8-bit mask | | h8mk | 8.5 | 48 | 48×48 8-bit mask | | t8mk | 10.0 | 128 | 128x128 8-bit mask | | ic04 | | 16 | 16x16 ARGB | | ic05 | | 32 | 32x32 ARGB | | icp4 | 10.7 | 16 | 16x16 icon in PNG format | | icp5 | 10.7 | 32 | 32x32 icon in PNG format | | icp6 | 10.7 | 64 | 64x64 icon in PNG format | | ic07 | 10.7 | 128 | 128x128 icon in PNG format | | ic08 | 10.5 | 256 | 256×256 icon in PNG format | | ic09 | 10.5 | 512 | 512×512 icon in PNG format | | ic10 | 10.7 | 1024 | 1024×1024 in 10.7 (or 512x512@2x "retina" in 10.8) icon in PNG format | | ic11 | 10.8 | 32 | 16x16@2x "retina" icon in PNG format | | ic12 | 10.8 | 64 | 32x32@2x "retina" icon in PNG format | | ic13 | 10.8 | 256 | 128x128@2x "retina" icon in PNG format | | ic14 | 10.8 | 512 | 256x256@2x "retina" icon in PNG format |