Convert PNG images to ICO
This module is a fork of kevva/to-ico
, removing the resize code. This code was quite old and had problematic dependencies, and my use case did not require it.
npm install --save @catdad/to-ico
const fs = require('fs');
const toIco = require('@catdad/to-ico');
const files = [
fs.readFileSync('unicorn-16x16.png'),
fs.readFileSync('unicorn-24x24.png'),
fs.readFileSync('unicorn-32x32.png'),
fs.readFileSync('unicorn-48x48.png'),
fs.readFileSync('unicorn-64x64.png'),
fs.readFileSync('unicorn-128x128.png'),
fs.readFileSync('unicorn-256x256.png')
];
toIco(files).then(buf => {
fs.writeFileSync('favicon.ico', buf);
});
Type: Array
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 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
library. If you have a colormap PNG you can convert it to an RGB/RGBA PNG with commonly used image editing tools.
- svg-app-icon - create high-quality desktop app icons for Windows, MacOS, and Linux using an SVG source
- to-ico - the original module that this is a fork of
- to-ico-cli - CLI for this module