Code Monkey home page Code Monkey logo

npm-icon-gen's Issues

Allow specifying icon file name

Currently, icons get saved to a directory as either "app.icns", "app.ico", or "favicon.ico". It makes sense to default the favicon to "favicon.ico", but users may want to use a name other than "app.icns" or "app.ico" for their application's icon. It would be nice to be able to specify the name of the saved icon file. My current workaround is to let the file write out as "app.ext" to a temp directory, then rename/move it using the user's preferred file name.

Relevant code block:
https://github.com/akabekobeko/npm-icon-gen/blob/master/src/lib/icon-generator.js#L123-L141

One possible implementation would be to add an object property to options. Something like:

icongen('./images', './dist', {
    modes: ['icns', 'ico'],
    names: { 'icns': 'my-icon' } // The ico file would default to "app"
});

It is an error to omit the modes in options

Example:

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

icongen( './test/data/sample.svg', './test', { report: true } )
.then( ( results ) => {
  console.log( results );
} )
.catch( ( err ) => {
  console.error( err );
} );

Error:

TypeError: Cannot read property 'forEach' of undefined
    at Function.generate (.../icon-gen/lib/icon-generator.js:161:12)
    at .../icon-gen/lib/icon-generator.js:84:25
    at .../icon-gen/lib/png-generator.js:92:11

Because the modes is undefined in IconGenerator.generate.

Drop the Node v4

Supports Node v4. use strict is necessary to use let, ...etc.

Drop the Node v4.

  • Dependent npm svg2png does not support Node v4
  • In Node LTS v4 was changed from Active to Maintenance to 2017-04-01

Test the CLI

Defines the parse of process.argv as a class, to test it.

CLI support

Support for command line interface.

$ icongen -i sample.svg -o ./ -p all

Implement an output mode

Implement an outpit mode.

  • CLI option is -m or --mode
  • Value is all, ico, icns, favicon
  • Separated by a multiple if comma, e.g. -m ico,favicon
  • Default is 'all'

Icns not working

Great project!
I tried generating the sample.svg from test using
icon-gen -i sample.svg -m icns -o ./icon-dist -r
The icns file itself shows the icon in Finder, and I can open it in preview and see the sizes there, however when I try to apply it to a folder (or electron app) the icon doesn't show up.
node v 6.7.0, mac os sierra.
I attached generated icon.

Icon generetor from SVG:
src: /Users/mifi/Desktop/icon-test/sample.svg
dir: /Users/mifi/Desktop/icon-test/icon-dist
SVG to PNG:
Create: /var/folders/fv/s06vd5bd28n2ymghb4k7gq140000gn/T/ba757b91-be2e-41a5-970c-489d32b621ed/16.png
Create: /var/folders/fv/s06vd5bd28n2ymghb4k7gq140000gn/T/ba757b91-be2e-41a5-970c-489d32b621ed/32.png
Create: /var/folders/fv/s06vd5bd28n2ymghb4k7gq140000gn/T/ba757b91-be2e-41a5-970c-489d32b621ed/64.png
Create: /var/folders/fv/s06vd5bd28n2ymghb4k7gq140000gn/T/ba757b91-be2e-41a5-970c-489d32b621ed/128.png
Create: /var/folders/fv/s06vd5bd28n2ymghb4k7gq140000gn/T/ba757b91-be2e-41a5-970c-489d32b621ed/256.png
Create: /var/folders/fv/s06vd5bd28n2ymghb4k7gq140000gn/T/ba757b91-be2e-41a5-970c-489d32b621ed/512.png
Create: /var/folders/fv/s06vd5bd28n2ymghb4k7gq140000gn/T/ba757b91-be2e-41a5-970c-489d32b621ed/1024.png
ICNS:
Create: /Users/mifi/Desktop/icon-test/icon-dist/app.icns

app.icns.zip

Fix a warning of consistent-return of ESLint

Example:

function sample() {
  return new Promise( ( resolve, reject ) => {
    const result = func();
    if( !( result ) ) { 
      return reject( new Error( 'Invalid result.' ) );
    }

    resolve();
  } );
}

Drop transpile by Babel

ES 2015 support improved in Node v 6 and later. Since this npm uses only the function of ES2015, transpile by Babel is unnecessary.

However, as import is not supported, it is necessary to change to require.

PNG support

To support the icon generation from PNG.

  • PNG is 32bit only
  • Size and file name can be fixed

Implement the FAVICON files generation

Size required below, from audreyr/favicon-cheat-sheet.

favicon.ico

Size Purpose
16x16 IE9 address bar, Pinned site Jump List/Toolbar/Overlay
24x24 IE9 Pinned site browser UI
32x32 New tab page in IE, taskbar button in Win 7+, Safari Read Later sidebar
48x48 Windows site icons
64x64 Windows site icons, Safari Reading List sidebar in HiDPI/Retina

PNG files

Size Name Purpose
32x32 favicon-32.png Certain old but not too old Chrome versions mishandle ico
57x57 favicon-57.png Standard iOS home screen (iPod Touch, iPhone first generation to 3G)
72x72 favicon-72.png iPad home screen icon
96x96 favicon-96.png GoogleTV icon
120x120 favicon-120.png iPhone retina touch icon (Change for iOS 7: up from 114x114)
128x128 favicon-128.png Chrome Web Store icon
144x144 favicon-144.png IE10 Metro tile for pinned site
152x152 favicon-152.png iPad retina touch icon (Change for iOS 7: up from 144x144)
195x195 favicon-195.png Opera Speed Dial icon
228x228 favicon-228.png Opera Coast icon

ICNS size adjustments

First, let me say thank you for this utility!! I needed a way to generate both .ico and .icns icons cross-platform, without special platform-dependent programs, and this utility is great! 💯

Now to the issue 😬

From Apple's documentation on .icns file creation:

A complete set consists of the following:

icon_16x16.png
[email protected]
icon_32x32.png
[email protected]
icon_128x128.png
[email protected]
icon_256x256.png
[email protected]
icon_512x512.png
[email protected]

From your documentation (and reading the code), I see two potential discrepancies. Please let me know if I'm wrong.

  1. You do not require a 16.png (16x16) image, which Apple recommends.
  2. You do require a 64.png (64x64) image, which Apple does not require. See correction in my next comment

What are your thoughts? And is fixing this just as simple as editing the array here?

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.