Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevva/to-ico
Convert PNG to ICO in memory
https://github.com/kevva/to-ico
buffer converter ico nodejs png
Last synced: 5 days ago
JSON representation
Convert PNG to ICO in memory
- Host: GitHub
- URL: https://github.com/kevva/to-ico
- Owner: kevva
- License: mit
- Created: 2016-04-18T07:30:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-03T07:12:55.000Z (over 4 years ago)
- Last Synced: 2024-12-17T04:03:04.986Z (17 days ago)
- Topics: buffer, converter, ico, nodejs, png
- Language: JavaScript
- Size: 48.8 KB
- Stars: 136
- Watchers: 7
- Forks: 19
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# to-ico [![Build Status](https://travis-ci.org/kevva/to-ico.svg?branch=master)](https://travis-ci.org/kevva/to-ico)
> Convert PNG to ICO in memory
## Install
```
$ npm install --save to-ico
```## Usage
```js
const fs = require('fs');
const toIco = require('to-ico');const files = [
fs.readFileSync('unicorn-16x16.png'),
fs.readFileSync('unicorn-32x32.png')
];toIco(files).then(buf => {
fs.writeFileSync('favicon.ico', buf);
});
```## API
### toIco(input, [options])
#### input
Type: `Array` `string`
Array of PNG image buffers.
The images must have a size of `16x16`, `24x24`, `32x32`, `48x48`, `64x64`, `128x128` or `256x256` and they must have an 8 bit per sample (channel) bit-depth (on Unix you can check this with the `file` command: RGB(A) is supported, while [colormap](https://en.wikipedia.org/wiki/Indexed_color) is not, because it's 8 bits per pixel instead of 8 bits per channel, which is 24 or 32 bits per pixel depending on the presence of the alpha channel). These are limitations in the underlying [`pngjs`](https://github.com/lukeapage/pngjs#pngjs) library. If you have a colormap PNG you can convert it to an RGB/RGBA PNG with commonly used image editing tools.
#### options
##### resize
Type: `boolean`
Default: `false`Use the largest image and resize to sizes defined using the [sizes](#sizes) option.
##### sizes
Type: `Array`
Default: `[16, 24, 32, 48, 64, 128, 256]`Array of sizes to use when resizing.
## Related
* [to-ico-cli](https://github.com/kevva/to-ico-cli) - CLI for this module
## License
MIT © [Kevin Martensson](http://github.com/kevva)