1.0.8 • Published 7 years ago

@keyvanfatehi/icon-gen v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

npm-icon-gen

node v6, v7 npm version Build Status Document

Generate an icon files from the SVG or PNG files.

Support formats

Supported the output format of the icon are following.

PlatformIcon
Windowsapp.ico or specified name.
OS Xapp.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,
  names: {
    ico: 'foo',
    icns: 'bar'
  }
};

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.

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.

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.

  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