From 284deae34dfb9ee295e09f1fc19fd1407904092f Mon Sep 17 00:00:00 2001 From: "amoblin@mbp" Date: Tue, 23 Sep 2014 15:33:19 +0800 Subject: [PATCH 1/5] update for commander --- lib/maker.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/maker.js b/lib/maker.js index f9bbd95..6db8c74 100755 --- a/lib/maker.js +++ b/lib/maker.js @@ -12,8 +12,8 @@ var program = require('commander') program .version(JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')).version) .usage('[debug] [options] [files]') - .option('-i --icon', '1024X1024的icon文件,默认为当前文件夹下的icon.png') - .option('-o --output', '要输出的目录,默认为当前文件夹') + .option('-i, --icon [icon path]', '1024X1024的icon文件,默认为当前文件夹下的icon.png', 'icon.png') + .option('-o, --output [output directory]', '要输出的目录,默认为当前文件夹', '.') .parse(process.argv); program.name = 'ios-icon'; @@ -31,4 +31,4 @@ var contents = path.join(output, "Contents.json"); ios_icon.make({ output: output, originIcon: icon -}); \ No newline at end of file +}); From b93e0d7e0aa6d6df2a430782ad4982e8d0917d07 Mon Sep 17 00:00:00 2001 From: "amoblin@mbp" Date: Tue, 23 Sep 2014 16:12:13 +0800 Subject: [PATCH 2/5] use graphicsmagick instead of imagemagick --- README.md | 4 ++-- lib/index.js | 27 ++++++++++++--------------- package.json | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f3f47e1..adbdb87 100644 --- a/README.md +++ b/README.md @@ -14,11 +14,11 @@ ios-icon 欢迎Pull Request和Star。 #Install -1. ios-icon使用了`imagemagick`,如果你还没有安装,在OSX中,你可以使用`brew install imagemagick`安装。 +1. ios-icon使用了`graphicsmagick`,如果你还没有安装,在OSX中,你可以使用`brew install graphicsmagick`安装。 2. 你必需安装好node.js环境(废话) 3. `npm install -g ios-icon`,建议使用-g全局安装 -如果你没有安装`imagemagick`,则可能会出现这样的错误: +如果你没有安装`graphicsmagick`,则可能会出现这样的错误: ````js events.js:72 diff --git a/lib/index.js b/lib/index.js index 6bec4bc..4ec41a1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,4 @@ -var im = require('imagemagick') +var im = require('gm') , path = require('path') , fs = require('fs') , async = require('async') @@ -51,21 +51,18 @@ maker.prototype.resize = function(item, done){ if(item.scale == '2x') size = size * 2; - im.resize({ - srcPath: this.options.originIcon, - srcData: this.srcData, - dstPath: dstPath, - quality: 1, - format: 'png', - width: size, - height: size - }, function(err, stdout, stderr){ - console.log(strformat('{0}创建完成', item.filename)); - if (err) throw err; - done(); - }); + im(this.options.originIcon) + .resize(size, size) + .quality(1) + .setFormat('png') + .write(dstPath, function(err) { + console.log(strformat('{0}创建完成', item.filename)); + console.log(err); + if (err) throw err; + done(); + }); }; exports.make = function(options){ new maker(options); -} \ No newline at end of file +} diff --git a/package.json b/package.json index a211c0e..d80e9ed 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "dependencies": { "underscore":"", "underscore.string": "", - "imagemagick": "", + "gm": "", "commander": "*", "async": "*", "strformat": "*" From d5501b71f85f78f4e542e06d8e4d7f653dad021f Mon Sep 17 00:00:00 2001 From: "amoblin@mbp" Date: Tue, 23 Sep 2014 16:15:25 +0800 Subject: [PATCH 3/5] add 3x images --- lib/config.js | 181 +++++++++++++++++++++----------------------------- lib/index.js | 3 +- 2 files changed, 78 insertions(+), 106 deletions(-) diff --git a/lib/config.js b/lib/config.js index 293d2ea..e1df19d 100644 --- a/lib/config.js +++ b/lib/config.js @@ -1,107 +1,80 @@ module.exports = { - "images" : [ - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "icon_29_iphone.png", - "scale" : "1x" - }, - { - "size" : "29x29", - "idiom" : "iphone", - "filename" : "icon_29_iphone@2x.png", - "scale" : "2x" - }, - { - "size" : "40x40", - "idiom" : "iphone", - "filename" : "icon_40_iphone@2x.png", - "scale" : "2x" - }, - { - "size" : "57x57", - "idiom" : "iphone", - "filename" : "icon_57_iphone.png", - "scale" : "1x" - }, - { - "size" : "57x57", - "idiom" : "iphone", - "filename" : "icon_57_iphone@2x.png", - "scale" : "2x" - }, - { - "size" : "60x60", - "idiom" : "iphone", - "filename" : "icon_60_iphone@2x.png", - "scale" : "2x" - }, - { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "icon_29_ipad.png", - "scale" : "1x" - }, - { - "size" : "29x29", - "idiom" : "ipad", - "filename" : "icon_29_ipad@2x.png", - "scale" : "2x" - }, - { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "icon_40_ipad.png", - "scale" : "1x" - }, - { - "size" : "40x40", - "idiom" : "ipad", - "filename" : "icon_40_ipad@2x.png", - "scale" : "2x" - }, - { - "size" : "50x50", - "idiom" : "ipad", - "filename" : "icon_50_ipad.png", - "scale" : "1x" - }, - { - "size" : "50x50", - "idiom" : "ipad", - "filename" : "icon_50_ipad@2x.png", - "scale" : "2x" - }, - { - "size" : "72x72", - "idiom" : "ipad", - "filename" : "icon_72_ipad.png", - "scale" : "1x" - }, - { - "size" : "72x72", - "idiom" : "ipad", - "filename" : "icon_72_ipad@2x.png", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "filename" : "icon_76_ipad.png", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "filename" : "icon_76_ipad@2x.png", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" + "images" : [ + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "AppIcon-29@2x.png", + "scale" : "2x" }, - "properties" : { - "pre-rendered" : true + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "AppIcon-29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "AppIcon-40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "AppIcon-40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "AppIcon-60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "AppIcon-60@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "AppIcon-29.png", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "filename" : "AppIcon-29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "AppIcon-40.png", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "filename" : "AppIcon-40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "AppIcon-76.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "AppIcon-76@2x.png", + "scale" : "2x" } -} \ No newline at end of file + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/lib/index.js b/lib/index.js index 4ec41a1..7c92b48 100644 --- a/lib/index.js +++ b/lib/index.js @@ -56,8 +56,7 @@ maker.prototype.resize = function(item, done){ .quality(1) .setFormat('png') .write(dstPath, function(err) { - console.log(strformat('{0}创建完成', item.filename)); - console.log(err); + console.log(strformat('{0} 创建完成', item.filename)); if (err) throw err; done(); }); From ef39a9acf75e68326feeafa3ac92e75c81e2b164 Mon Sep 17 00:00:00 2001 From: "amoblin@mbp" Date: Thu, 11 Jun 2015 06:07:03 +0800 Subject: [PATCH 4/5] fix 3@ images size bug --- lib/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/index.js b/lib/index.js index 7c92b48..7a38abf 100644 --- a/lib/index.js +++ b/lib/index.js @@ -49,6 +49,7 @@ maker.prototype.resize = function(item, done){ var dstPath = path.join(this.options.output, item.filename); var size = item.size.replace(/(\d+).+/, "$1"); if(item.scale == '2x') size = size * 2; + if(item.scale == '3x') size = size * 3; im(this.options.originIcon) From ffbecdb70735131cbfa765fc6daac7c7394e36be Mon Sep 17 00:00:00 2001 From: "amoblin@mbp" Date: Mon, 21 Dec 2015 07:57:02 +0800 Subject: [PATCH 5/5] update Contents.json template to latest version --- lib/config.js | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/lib/config.js b/lib/config.js index e1df19d..0f95450 100644 --- a/lib/config.js +++ b/lib/config.js @@ -1,5 +1,12 @@ -module.exports = { +module.exports = +{ "images" : [ + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "AppIcon-29.png", + "scale" : "1x" + }, { "size" : "29x29", "idiom" : "iphone", @@ -24,6 +31,18 @@ module.exports = { "filename" : "AppIcon-40@3x.png", "scale" : "3x" }, + { + "idiom" : "iphone", + "size" : "57x57", + "filename" : "AppIcon-57.png", + "scale" : "1x" + }, + { + "idiom" : "iphone", + "size" : "57x57", + "filename" : "AppIcon-57@2x.png", + "scale" : "2x" + }, { "size" : "60x60", "idiom" : "iphone", @@ -43,8 +62,8 @@ module.exports = { "scale" : "1x" }, { - "idiom" : "ipad", "size" : "29x29", + "idiom" : "ipad", "filename" : "AppIcon-29@2x.png", "scale" : "2x" }, @@ -55,11 +74,35 @@ module.exports = { "scale" : "1x" }, { - "idiom" : "ipad", "size" : "40x40", + "idiom" : "ipad", "filename" : "AppIcon-40@2x.png", "scale" : "2x" }, + { + "idiom" : "ipad", + "size" : "50x50", + "filename" : "AppIcon-50.png", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "50x50", + "filename" : "AppIcon-50@2x.png", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "72x72", + "filename" : "AppIcon-72.png", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "72x72", + "filename" : "AppIcon-72@2x.png", + "scale" : "2x" + }, { "size" : "76x76", "idiom" : "ipad",