Skip to content
forked from fiahfy/ico

ICO file format parser and builder

License

Notifications You must be signed in to change notification settings

igor-arkhipov/ico

 
 

Repository files navigation

ico

badge

ICO file format parser and builder.

Installation

npm install @igor-arkhipov/ico

Usage

Parsing

import fs from 'fs'
import { Ico } from '@igor-arkhipov/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 '@igor-arkhipov/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