Socket
Socket
Sign inDemoInstall

icon-gen

Package Overview
Dependencies
157
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    icon-gen

Generate an icon files from the SVG or PNG files


Version published
Weekly downloads
63K
increased by1.44%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

v1.2.0

Features

  • Supports is32 and il32 #71

Readme

Source

npm-icon-gen

Support Node of LTS npm version Build Status Document Standard - JavaScript Style Guide

Generate an icon files from the SVG or PNG files.

Node.js requirements

This module depends on svg2png. Therefore we need Node v6 or later. The following is a quotation from README of svg2png.

svg2png uses the latest in ES2015 features, and as such requires a recent version of Node.js. Only the 6.x series onward is supported.

Support formats

Supported the output format of the icon are following.

PlatformIcon
Windowsapp.ico or specified name.
macOSapp.icns or specified name.
Faviconfavicon.ico and favicon-XX.png.

Installation

$ npm install icon-gen

Usage

SVG

SVG files are rendering to PNG file in svg2png. Rendering files is output to a temporary directory of the each OS.

Rendering of svg2png is run by phantomjs. Please use the PNG directory If the rendering quality there is a problem.

const icongen = require('icon-gen');

const options = {
  report: true
};

icongen('./sample.svg', './dist', options)
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.error(err)
});

PNG

Generate an icon files from the directory of PNG files.

const icongen = require('icon-gen');

const options = {
  type: 'png',
  report: true
};

icongen('./images', './dist', options)
.then((results) => {
  console.log(results);
} )
.catch((err) => {
  console.error(err);
});

Required PNG files is below. Favicon outputs both the ICO and PNG files ( see: audreyr/favicon-cheat-sheet ).

NameSizeICOICNSFav ICOFav PNG
16.png16x16
24.png24x24
32.png32x32
48.png48x48
57.png57x57
64.png64x64
72.png72x72
96.png96x96
120.png120x120
128.png128x128
144.png144x144
152.png152x152
195.png195x195
228.png228x228
256.png256x256
512.png512x512
1024.png1024x1024

Node API

icongen

icongen is promisify function.

icongen(src, dest[, options])

NameTypeDescription
srcStringPath of the SVG file or PNG files directory that becomes the source.
destStringDestination directory path.
optionsObjectOptions.

options:

NameTypeDescription
typeStringType of input file. Allowed value is a svg or png. 'svg' is SVG file, png is PNG files directory. Default is svg.
modesArrayMode of output files. Allow value is a ico, icns, favicon and all. Default is all.
namesObjectChange an output file names for ICO and ICNS.
reportBooleanDisplay the process reports. Default is false, disable a report.
sizesObjectList of sizes to include for ICO and ICNS.

names:

Use this property is specified without an extension. Default name is the app.

NameTypeDescription
icoStringName of the ico file.
icnsStringName of the icns file.

sizes:

Use this property is specified without an extension. Default name is the app.

NameTypeDescription
icoArrayList of sizes for the ico file.
icnsArrayList of sizes for the icns file.

CLI

Usage: icon-gen [OPTIONS]

  Generate an icon from the SVG or PNG file.

  Options:
    -h, --help    Display this text.

    -v, --version Display the version number.

    -i, --input   Path of the SVG file or PNG file directory.

    -o, --output  Path of the output directory.

    -t, --type    Type of the input file.
                  'svg' is the SVG file, 'png' is the PNG files directory.
                  Allowed values: svg, png
                  Default is 'svg'.

    -m, --modes   Mode of the output files.
                  Allowed values: ico, icns, favicon, all
                  Default is 'all'.

    -n, --names   Change an output file names for ICO and ICNS.
                  ex: 'ico=foo,icns=bar'
                  Default is 'app.ico' and 'app.ico'.

    -r, --report  Display the process reports.
                  Default is disable.

    -s, --sizes   List of sizes to include for ICO and ICNS.
                  ex: 'ico=[12,24,32],icns=[12,24,64]'

  Examples:
    $ icon-gen -i sample.svg -o ./dist -r
    $ icon-gen -i ./images -o ./dist -t png -r
    $ icon-gen -i sample.svg -o ./dist -m ico,favicon -r
    $ icon-gen -i sample.svg -o ./dist -n ico=foo,icns=bar

  See also:
    https://github.com/akabekobeko/npm-icon-gen

ChangeLog

License

Keywords

FAQs

Last updated on 21 Nov 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc