Socket
Socket
Sign inDemoInstall

icon-gen

Package Overview
Dependencies
88
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 3.0.0

4

dist/bin/cli.js

@@ -118,5 +118,5 @@ "use strict";

const exec = (argv) => {
const options = exports.parseArgv(argv);
return index_1.default(options.input, options.output, options.icon);
const options = (0, exports.parseArgv)(argv);
return (0, index_1.default)(options.input, options.output, options.icon);
};
exports.default = exec;

@@ -8,4 +8,4 @@ #!/usr/bin/env node

const cli_js_1 = __importDefault(require("./cli.js"));
cli_js_1.default(process.argv).catch((err) => {
(0, cli_js_1.default)(process.argv).catch((err) => {
console.error(err);
});

@@ -60,3 +60,3 @@ "use strict";

logger.log('Favicon:');
const targets = png_1.filterImagesBySizes(images, sizes);
const targets = (0, png_1.filterImagesBySizes)(images, sizes);
const results = [];

@@ -87,4 +87,4 @@ for (const image of targets) {

};
const results = await exports.generatePNG(images, dir, opt.name, opt.pngSizes, logger);
results.push(await ico_1.default(png_1.filterImagesBySizes(images, opt.icoSizes), dir, logger, {
const results = await (0, exports.generatePNG)(images, dir, opt.name, opt.pngSizes, logger);
results.push(await (0, ico_1.default)((0, png_1.filterImagesBySizes)(images, opt.icoSizes), dir, logger, {
name: ICO_FILE_NAME,

@@ -91,0 +91,0 @@ sizes: opt.icoSizes

@@ -116,5 +116,5 @@ "use strict";

// Compress
results.colors = results.colors.concat(rle_1.packICNS(r));
results.colors = results.colors.concat(rle_1.packICNS(g));
results.colors = results.colors.concat(rle_1.packICNS(b));
results.colors = results.colors.concat((0, rle_1.packICNS)(r));
results.colors = results.colors.concat((0, rle_1.packICNS)(g));
results.colors = results.colors.concat((0, rle_1.packICNS)(b));
return results;

@@ -243,3 +243,3 @@ };

try {
const targets = png_1.filterImagesBySizes(images, opt.sizes);
const targets = (0, png_1.filterImagesBySizes)(images, opt.sizes);
await createIconFile(targets, dest);

@@ -246,0 +246,0 @@ }

@@ -127,3 +127,3 @@ "use strict";

const readPNGs = (images, sizes) => {
const targets = png_1.filterImagesBySizes(images, sizes);
const targets = (0, png_1.filterImagesBySizes)(images, sizes);
return targets.map((image) => {

@@ -130,0 +130,0 @@ const data = fs_1.default.readFileSync(image.filePath);

@@ -102,9 +102,9 @@ "use strict";

if (options.icns) {
results.push(await icns_1.default(images, dir, logger, options.icns));
results.push(await (0, icns_1.default)(images, dir, logger, options.icns));
}
if (options.ico) {
results.push(await ico_1.default(images, dir, logger, options.ico));
results.push(await (0, ico_1.default)(images, dir, logger, options.ico));
}
if (options.favicon) {
const files = await favicon_1.default(images, dir, logger, options.favicon);
const files = await (0, favicon_1.default)(images, dir, logger, options.favicon);
for (const file of files) {

@@ -166,3 +166,3 @@ results.push(file);

logger.log(' dir: ' + destDirPath);
const workDir = path_1.default.join(os_1.default.tmpdir(), uuid_1.v4());
const workDir = path_1.default.join(os_1.default.tmpdir(), (0, uuid_1.v4)());
fs_1.default.mkdirSync(workDir);

@@ -173,3 +173,3 @@ if (!fs_1.default.existsSync(workDir)) {

try {
const images = await png_1.default(svgFilePath, workDir, getRequiredPNGImageSizes(options), logger);
const images = await (0, png_1.default)(svgFilePath, workDir, getRequiredPNGImageSizes(options), logger);
const results = await generate(images, destDirPath, options, logger);

@@ -176,0 +176,0 @@ del_1.default.sync([workDir], { force: true });

@@ -9,4 +9,3 @@ "use strict";

const path_1 = __importDefault(require("path"));
const util_1 = __importDefault(require("util"));
const svg2png_1 = __importDefault(require("svg2png"));
const sharp_1 = __importDefault(require("sharp"));
/**

@@ -41,8 +40,9 @@ * Filter by size to the specified image information.

logger.log(' Create: ' + dest);
const buffer = svg2png_1.default.sync(svg, { width: size, height: size });
if (!buffer) {
throw new Error('Failed to write the image, ' + size + 'x' + size);
}
const writeFileAsync = util_1.default.promisify(fs_1.default.writeFile);
await writeFileAsync(dest, buffer);
await (0, sharp_1.default)(svg)
.png({ compressionLevel: 9 })
.resize(size, size, {
fit: 'contain',
background: { r: 0, g: 0, b: 0, alpha: 0 }
})
.toFile(dest);
return { size: size, filePath: dest };

@@ -49,0 +49,0 @@ };

@@ -175,3 +175,3 @@ "use strict";

if (current === next) {
dest = dest.concat(exports.packBitsLiteralToResult(literals));
dest = dest.concat((0, exports.packBitsLiteralToResult)(literals));
literals = [];

@@ -202,3 +202,3 @@ const maxJ = max <= i + MAX_LITERAL_LENGTH ? max - i - 1 : MAX_LITERAL_LENGTH;

if (literals.length === MAX_LITERAL_LENGTH) {
dest = dest.concat(exports.packBitsLiteralToResult(literals));
dest = dest.concat((0, exports.packBitsLiteralToResult)(literals));
literals = [];

@@ -210,3 +210,3 @@ }

literals.push(current);
dest = dest.concat(exports.packBitsLiteralToResult(literals));
dest = dest.concat((0, exports.packBitsLiteralToResult)(literals));
literals = [];

@@ -213,0 +213,0 @@ }

{
"name": "icon-gen",
"description": "Generate an icon files from the SVG or PNG files",
"version": "2.1.0",
"version": "3.0.0",
"author": "akabeko (http://akabeko.me/)",

@@ -9,3 +9,3 @@ "license": "MIT",

"engines": {
"node": ">= 10"
"node": ">= 12"
},

@@ -41,21 +41,21 @@ "main": "dist/lib/index.js",

"dependencies": {
"commander": "^6.2.0",
"commander": "^8.3.0",
"del": "^6.0.0",
"mkdirp": "^1.0.4",
"pngjs": "^6.0.0",
"svg2png": "4.1.1",
"uuid": "^8.3.1"
"sharp": "^0.29.3",
"uuid": "^8.3.2"
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/jest": "^26.0.16",
"@types/mkdirp": "^1.0.1",
"@types/node": "^14.14.10",
"@types/pngjs": "^3.4.2",
"@types/svg2png": "^4.1.0",
"@types/uuid": "^8.3.0",
"jest": "^26.6.3",
"ts-jest": "^26.4.4",
"typescript": "^4.1.2"
"@types/jest": "^27.0.3",
"@types/mkdirp": "^1.0.2",
"@types/node": "^16.11.11",
"@types/pngjs": "^6.0.1",
"@types/sharp": "^0.29.4",
"@types/uuid": "^8.3.3",
"jest": "^27.4.3",
"ts-jest": "^27.0.7",
"typescript": "^4.5.2"
}
}

@@ -5,3 +5,3 @@ # npm-icon-gen

[![npm version](https://badge.fury.io/js/icon-gen.svg)](https://badge.fury.io/js/icon-gen)
[![Build Status](https://travis-ci.org/akabekobeko/npm-icon-gen.svg?branch=master)](https://travis-ci.org/akabekobeko/npm-icon-gen)
![test](https://github.com/akabekobeko/npm-icon-gen/workflows/test/badge.svg)

@@ -32,6 +32,4 @@ Generate an icon files from the **SVG** or **PNG** files.

SVG files are rendering to PNG file in **svg2png**. Rendering files is output to a temporary directory of the each OS.
SVG files are rendering to PNG file in [sharp](https://www.npmjs.com/package/sharp). Rendering files is output to a temporary directory of the each OS.
Rendering of svg2png is run by [phantomjs](https://www.npmjs.com/package/phantomjs). Please use the PNG directory If the rendering quality there is a problem.
```js

@@ -49,2 +47,12 @@ const icongen = require('icon-gen')

Stopped using [svg2png](https://www.npmjs.com/package/svg2png) because of its dependency on [phantomjs](https://www.npmjs.com/package/phantomjs), which is deprecated.
The quality of PNG generated from SVG will change, so if you need the previous results, use icon-gen v2.1.0.
```
$ npm install icon-gen@2.1.0
```
In the future, I may add SVG to PNG conversion by Chromium via [puppeteer-core](https://www.npmjs.com/package/puppeteer-core) in addition to [sharp](https://www.npmjs.com/package/sharp).
### PNG

@@ -55,11 +63,11 @@

```js
const icongen = require('icon-gen');
const icongen = require('icon-gen')
icongen('./images', './icons', { report: true })
.then((results) => {
console.log(results);
} )
.catch((err) => {
console.error(err);
});
.then((results) => {
console.log(results)
})
.catch((err) => {
console.error(err)
})
```

@@ -66,0 +74,0 @@

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