Created
October 17, 2018 04:45
-
-
Save jerrythomas/f654ff22ac5864fb814c066c7a0dc692 to your computer and use it in GitHub Desktop.
Generate App Icons
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sharp = require('sharp'); | |
const fs = require('fs-extra'); | |
function generateIcons(sourceFile){ | |
let sizes = [512, 384, 256, 192, 152, 144, 128, 96, 72, 32]; | |
fs.ensureDirSync('assets/icons'); | |
sizes.forEach(size => { | |
let iconFile = `assets/icons/icon-${size}x${size}.png`; | |
if (size == 32) | |
iconFile = 'favicon.ico'; | |
sharp(sourceFile) | |
.resize(size, size) | |
.toFile(iconFile, function (err) { | |
if (err) { | |
console.error(`Error while generating ${iconFile}`); | |
console.error(err); | |
} | |
}); | |
}); | |
} | |
var args = process.argv.slice(2); | |
console.log(args[0]); | |
generateIcons(args[0]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment