https://github.com/andmitr/favicon-generator-cli
A Node.js CLI tool that generates a full set of favicons from PNG and SVG source images. Outputs optimized icons in multiple sizes and formats (ICO, Apple Touch Icon, Android Chrome, etc.) ready for cross-browser use.
https://github.com/andmitr/favicon-generator-cli
cli favicon icons image-processing nodejs tools utility
Last synced: 3 months ago
JSON representation
A Node.js CLI tool that generates a full set of favicons from PNG and SVG source images. Outputs optimized icons in multiple sizes and formats (ICO, Apple Touch Icon, Android Chrome, etc.) ready for cross-browser use.
- Host: GitHub
- URL: https://github.com/andmitr/favicon-generator-cli
- Owner: andmitr
- License: mit
- Created: 2025-05-29T04:00:15.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2026-03-08T04:39:55.000Z (4 months ago)
- Last Synced: 2026-03-08T09:51:11.776Z (4 months ago)
- Topics: cli, favicon, icons, image-processing, nodejs, tools, utility
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Favicon Generator CLI
A Node.js CLI tool that generates a full set of favicons from PNG and SVG source images. Outputs optimized icons in
multiple sizes and formats (ICO, Apple Touch Icon, Android Chrome, etc.) ready for cross-browser use.
[](LICENSE)
[](https://www.npmjs.com/package/favicon-generator-cli)
[](https://github.com/andmitr/favicon-generator-cli/pkgs/container/favicon-generator-cli)
## Table of Contents
- [Features](#features)
- [Dependencies](#dependencies)
- [Installation](#installation)
- [Usage](#usage)
- [Sponsorship](#sponsorship)
- [License](#license)
## Features
- **Generated files:**
- `favicon.ico` (multi-size: 16px, 32px, 48px, 256px from PNG)
- `favicon.svg` (optimized from source SVG)
- `favicon-16x16.png`
- `favicon-32x32.png`
- `favicon-48x48.png`
- `apple-touch-icon.png` (180×180px)
- `icon-192.png` and `icon-512.png` (for Android/PWA manifest)
- **PNG and SVG input:** Accepts both formats as source material. Defaults
to `./favicon_src.png` and `./favicon_src.svg`.
- **Image optimization:** Uses `sharp` for PNG resizing,
`imagemin` + `imagemin-pngquant` for PNG compression, `svgo` for SVG
optimization, and `png2icons` for ICO generation.
- **Custom output directory:** Specify an output path with `--dist`, or let
the tool create a `favicons_xxxx` directory in the current working directory.
- **CLI arguments:** Simple command-line interface with `--help` for usage
details.
- **Error handling:** Reports missing source files and image processing
failures.
> **Note:** This tool does not generate a 512×512 maskable icon for PWA
> safe-zone compliance. This must be created separately using a tool
> like [maskable.app](https://maskable.app/editor). Make sure your PWA
> manifest references the maskable icon alongside other icons.
## Dependencies
- [Node.js](https://nodejs.org/) v24 LTS (tested and recommended version, specified in `.nvmrc`)
- Docker (if you choose to run the tool via container)
- npm packages (installed automatically with the tool):
- imagemin
- imagemin-pngquant
- sharp
- svgo
- png2icons
## Installation
### From npm
```bash
sudo npm install -g favicon-generator-cli
```
### From GitHub
```bash
sudo npm install -g git+https://github.com/andmitr/favicon-generator-cli.git
```
### From Docker Registry (GitHub Container Registry)
```bash
docker pull ghcr.io/andmitr/favicon-generator-cli:latest
```
To use a shorter image name locally, create a tag:
```shell
docker tag ghcr.io/andmitr/favicon-generator-cli:latest favgen
```
### Uninstall
```bash
sudo npm uninstall -g favicon-generator-cli
```
### Troubleshooting: libvips conflict
If you have libvips installed system-wide, sharp installation may fail. Use SHARP_IGNORE_GLOBAL_LIBVIPS=1 to bypass it:
```bash
# From npm
sudo SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install -g favicon-generator-cli
# From GitHub
sudo SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install -g git+https://github.com/andmitr/favicon-generator-cli.git
# Run without installation
SHARP_IGNORE_GLOBAL_LIBVIPS=1 npx --package=favicon-generator-cli favgen
```
## Usage
```bash
favgen [--png ] [--svg ] [--dist ]
```
### Docker
```bash
docker run --rm -v "$PWD:/app" ghcr.io/andmitr/favicon-generator-cli:latest [--png ] [--svg ] [--dist ]
```
If you created the local favgen image tag:
```shell
docker run --rm -v "$PWD:/app" favgen [--png ] [--svg ] [--dist ]
```
#### Shortcuts (Alias)
To avoid typing the long Docker command every time, add this alias to your ~/.bashrc or ~/.zshrc:
```shell
alias favgend='docker run --rm -v "$PWD:/app" ghcr.io/andmitr/favicon-generator-cli:latest'
```
Then you can use it just like the native command:
```shell
favgend --help
favgend --dist favicons
```
### Run without installation
```bash
npx --package=favicon-generator-cli favgen [--png ] [--svg ] [--dist ]
```
### Arguments
| Argument | Alias | Default | Description |
|----------|-------|-------------------|--------------------------------------|
| --png | -p | ./favicon_src.png | Path to the source PNG image |
| --svg | -s | ./favicon_src.svg | Path to the source SVG image |
| --dist | -d | ./favicons_xxxx | Output directory for generated files |
| --help | -h | — | Show help message and exit |
### Examples
```bash
# Custom source files and output directory
favgen --png ./myicon.png --svg ./myicon.svg --dist ./favs
# Default source files, custom output directory
favgen --dist icons
```
### HTML Usage
Add the generated favicons to the `` of your HTML:
```html
```
Reference `icon-192.png` and `icon-512.png` in your `manifest.webmanifest`.
## Sponsorship
[](https://boosty.to/andmitr/donate)

```
1CCnwAvJYEoDVGM7vsBg2Q99cF9EHtBVaY
```
-168363?style=flat&logo=tether&logoColor=white&logoSize=auto)
```
0x54f0ccc6b2987de454f69f2814fc9202bcfb74fe
```
## License
MIT Licensed. See [LICENSE](LICENSE) for details.