https://github.com/egy186/icojs
A JavaScript library to parse ICO.
https://github.com/egy186/icojs
favicon ico icon
Last synced: 3 months ago
JSON representation
A JavaScript library to parse ICO.
- Host: GitHub
- URL: https://github.com/egy186/icojs
- Owner: egy186
- License: mit
- Created: 2014-03-16T17:00:06.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2025-10-19T01:43:25.000Z (9 months ago)
- Last Synced: 2025-10-22T11:54:48.232Z (9 months ago)
- Topics: favicon, ico, icon
- Language: JavaScript
- Homepage: http://egy186.github.io/icojs
- Size: 4.16 MB
- Stars: 54
- Watchers: 2
- Forks: 11
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# icojs
[](https://www.npmjs.com/package/icojs)
[](https://github.com/egy186/icojs/actions/workflows/ci.yml)
[](https://coveralls.io/github/egy186/icojs?branch=main)
A JavaScript library to use ICO.
Works on both Node.js and the browser.
## Install
```sh
npm install icojs
```
```js
import { decodeIco, isIco } from 'icojs';
```
A UMD bundle is also available for browsers.
```html
```
## Example
### Node.js:
```js
import { readFile, writeFile } from 'node:fs/promises';
import { decodeIco } from 'icojs';
const buffer = await readFile('favicon.ico');
const images = await decodeIco(buffer, 'image/png');
// save as png files
images.forEach(image => {
const file = `${image.width}x${image.height}-${image.bpp}bit.png`;
const data = Buffer.from(image.buffer);
writeFile(file, data);
});
```
### Browser:
```html
document.querySelector('#input-file').addEventListener('change', async evt => {
const file = evt.target.files[0];
const buffer = await file.arrayBuffer();
const images = await ICO.decodeIco(buffer);
// logs images
console.dir(images);
});
```
## Demo
[https://egy186.github.io/icojs/demo.html](https://egy186.github.io/icojs/demo.html)
## API Documentation
[https://egy186.github.io/icojs/](https://egy186.github.io/icojs/)