@fiahfy/ico

中文文档
0.0.5发布于 2020/12/29MITTypeScriptCommonJS近 30 天下载 4931

ICO file format parser and builder

原始使用文档
文档目录11 节
  1. Installation
  2. Usage
  3. Parsing
  4. Building
  5. API
  6. Class: Ico
  7. Class: IcoImage
  8. Class: IcoInfoHeader
  9. Class: IcoFileHeader
  10. Specifications
  11. Supported Size

ico

badge

ICO file format parser and builder.

Installation

npm install @fiahfy/ico

Usage

Parsing

import fs from 'fs'
import { Ico } from '@fiahfy/ico'

const buf = fs.readFileSync('icon.ico')
const ico = Ico.from(buf)
console.log(ico.fileHeader) // IcoFileHeader { reserved: 0, type: 1, count: 7 }
console.log(ico.infoHeaders[0]) // IcoInfoHeader { width: 16, height: 16, ... }

Building

import fs from 'fs'
import { Ico, IcoImage } from '@fiahfy/ico'

const ico = new Ico()
let buf

buf = fs.readFileSync('128x128.png')
image = IcoImage.fromPNG(buf)
ico.append(image)

buf = fs.readFileSync('256x256.png')
image = IcoImage.fromPNG(buf)
ico.append(image)

/* Some other PNG files */

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

API

Class: Ico

static from(buffer)

Create ICO from the icon buffer.

buffer

Type: Buffer

The ICO icon buffer.

append(image)

Adds ICO image at the end.

image

Type: IcoImage

The ICO Image to append.

insert(image, index)

Inserts ICO image at the specified position.

image

Type: IcoImage

The ICO Image to insert.

index

Type: number

The position at which to insert the ICO Image.

remove(index)

Removes ICO image at the specified position.

index

Type: number

The position of the ICO Image to remove.

fileHeader

Type: IcoFileHeader

Return the file header on the ICO.

infoHeaders

Type: IcoInfoHeader[]

Return the ICO info header on the ICO.

images

Type: IcoImage[]

Return the ICO images on the ICO.

data

Type: Buffer

Return the ICO buffer.

Class: IcoImage

static from(buffer)

Create ICO image from the buffer.

buffer

Type: Buffer

The ICO image buffer.

static fromPNG(buffer)

Create ICO Image from the PNG image buffer.

buffer

Type: Buffer

The PNG image buffer.

Class: IcoInfoHeader

static from(buffer)

Create ICO info header from the buffer.

buffer

Type: Buffer

The ICO info header buffer.

Class: IcoFileHeader

static from(buffer)

Create ICO file header from the buffer.

buffer

Type: Buffer

The ICO file header buffer.

Specifications

Supported Size

Size
16x16
24x24
32x32
48x48
64x64
128x128
256x256

版本与发布记录

@fiahfy/ico 共发布 5 个版本,首次发布于 2018/10/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.5latest2020/12/295 年前
0.0.42019/11/156 年前
0.0.32019/07/277 年前
0.0.22018/10/218 年前
0.0.12018/10/078 年前

关于 @fiahfy/ico 的常见问题

@fiahfy/ico 是什么?

ICO file format parser and builder

如何安装 @fiahfy/ico?

在项目目录运行 npm install @fiahfy/ico,或使用 pnpm add / yarn add / bun add。

@fiahfy/ico 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fiahfy/ico 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@fiahfy/ico 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=8。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fiahfy/ico 可以商用吗?

@fiahfy/ico 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fiahfy/ico 的下载量有多少?

根据 npm 官方下载统计,@fiahfy/ico 在 2026/10/15 – 2026/11/13 这 30 天内被下载 4,931 次,日均约 164 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fiahfy/ico 还在维护吗?

最新版本 0.0.5 发布于 2020/12/29(5 年前);至今共发布 5 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/10/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。