akabekobeko / npm-icon-gen Goto Github PK
View Code? Open in Web Editor NEWIcon file generator for Windows, macOS, Web
License: MIT License
Icon file generator for Windows, macOS, Web
License: MIT License
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"
});
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
.
PNG images but the upper left corner is the origin, DIB is the lower left corner at the origin.
Supports Node v4. use strict
is necessary to use let
, ...etc.
Drop the Node v4.
Defines the parse of process.argv
as a class, to test it.
Support for command line interface.
$ icongen -i sample.svg -o ./ -p all
Adopt JavaScript Standard Style as coding rule. Also add a check by ESLint.
Mocha supports the Promise.
Can be handled the end of the asynchronous processing without a callback.
Implement an outpit mode.
-m
or --mode
all
, ico
, icns
, favicon
-m ico,favicon
Badge to add npm version
and ESDoc
.
Move the setting to the esdoc
property of package.json
.
Icon generetor from SVG:
Opening an error the generated ICO files in the following applications.
View the details of the process to stdout in report mode.
Unnecessary had been implemented from PNG for DIB conversion.
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
Mode check of IconGenerator has not been implemented.
Example:
function sample() {
return new Promise( ( resolve, reject ) => {
const result = func();
if( !( result ) ) {
return reject( new Error( 'Invalid result.' ) );
}
resolve();
} );
}
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
.
To support the icon generation from PNG.
Size required below, from audreyr/favicon-cheat-sheet.
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 |
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 |
Support the Travic CI, add a badge to README.
There is a problem with the ES2015 class of export. index.js should be a simple wapper of "lib/main.js".
Examine and fix the problem of #43 again.
This property has been deleted in the #11. They must get their own set in ICNS.
The conversion from SVG use npm svg2png, PNG file to generate all the required size.
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.
16.png
(16x16) image, which Apple recommends.64.png
(64x64) image, which Apple does not require.What are your thoughts? And is fixing this just as simple as editing the array here?
Thank you!
webcatalog/webcatalog#94
I tried to add Retina icon types but it didn't play well. #52
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.