Node lib to create ICO files containing PNG images:
const fs = require('fs'); const pack = require('ico-packer'); const ico = pack([ fs.readFileSync('16x16.png'), fs.readFileSync('32x32.png'), fs.readFileSync('48x48.png'), ]); fs.writeFileSync('favicon.ico', ico);
ICO remains a popular format for the favicon. Historically ICO contained bitmap images, but support for PNG was introduced in Windows Vista and has been broadly adopted since. Using PNG within ICO leads to much smaller file sizes, but most icon composers still produce ICO files containing bitmap images.
This library exists to create ICO files containing PNG images. It does not convert to BMP or support BMP composition.
- PNG images must be <= 256px
- PNG images must be square
- PNG images must be 32-bit (24bit+alpha)
Apps and operating systems vary in their tolerance for these rules (Windows 10 is persnickety, macOS quite forgiving). To avoid incompatibilities, this lib insists on them.