diff --git a/README.md b/README.md index b9e5b63..9c9085f 100644 --- a/README.md +++ b/README.md @@ -51,17 +51,17 @@ You can provide a platform-specific icon by creating a subfolder with the name o ### Requirements -#### ImageMagick +#### GraphicsMagick Install on a Mac: - $ brew install imagemagick + $ brew install graphicsmagick On linux: - $ sudo apt-get install imagemagick + $ sudo apt-get install graphicsmagick -On windows, see http://www.imagemagick.org/script/binary-releases.php#windows. Also, on the version 7.0.0+ you will have to check the 'Install legacy utilities' option (which is not enabled by default). +On windows, see http://www.graphicsmagick.org/INSTALL-windows.html. --- diff --git a/index.js b/index.js index 82abbc7..d6e9195 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ var fs = require('fs'); var path = require('path'); -var ig = require('imagemagick'); +var gm = require('gm'); var colors = require('colors'); var _ = require('underscore'); var Q = require('q'); @@ -273,21 +273,19 @@ var generateIcon = function (platform, icon) { if (fs.existsSync(platformIconPath)) { srcPath = platformIconPath; } - ig.resize({ - srcPath: srcPath, - dstPath: filePath, - quality: 1, - format: icon.name.replace(/.*\.(\w+)$/i, '$1').toLowerCase(), - width: icon.size, - height: icon.size, - }, function (err, stdout, stderr) { - if (err) { - deferred.reject(err); - } else { - deferred.resolve(); - display.success(icon.name + ' created'); - } - }); + gm(srcPath) + .quality(100) + .resize(icon.size, icon.size) + .setFormat(icon.name.replace(/.*\.(\w+)$/i, '$1').toLowerCase()) + .write(filePath, function(err){ + if (err) { + deferred.reject(err); + } + else{ + deferred.resolve(); + display.success(icon.name + ' created'); + } + }) } catch (error) { deferred.reject(err); } @@ -381,21 +379,20 @@ var generateSplash = function (platform, splash) { if (fs.existsSync(platformIconPath)) { srcPath = platformIconPath; } - ig.crop({ - srcPath: srcPath, - dstPath: filePath, - quality: 1, - format: splash.name.replace(/.*\.(\w+)$/i, '$1').toLowerCase(), - width: splash.width, - height: splash.height, - }, function (err, stdout, stderr) { - if (err) { - deferred.reject(err); - } else { - deferred.resolve(); - display.success(splash.name + ' created'); - } - }); + + gm(srcPath) + .gravity('Center') + .resize( (splash.width < splash.height)? null : splash.width, (splash.width < splash.height)? splash.height : null) + .extent(splash.width, splash.height) + .quality(100) + .write(filePath, function(err){ + if (err) { + deferred.reject(err); + } else { + deferred.resolve(); + display.success(splash.name + ' created'); + } + }) } catch (error) { deferred.reject(err); } diff --git a/package.json b/package.json index 30a798a..bcf8745 100644 --- a/package.json +++ b/package.json @@ -1,47 +1,47 @@ { - "name": "splashicon-generator", - "version": "0.2.12", - "description": "Automatic icon & splash resizing for PhoneGap", - "main": "index.js", - "preferGlobal": false, - "bin": { - "splashicon-generator": "./bin/splashicon-generator" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "repository": { - "type": "git", - "url": "git://github.com/eberlitz/splashicon-generator.git" - }, - "keywords": [ - "cordova", - "phonegap", - "icon", - "splash", - "resize" - ], - "author": { - "name": "Eduardo Eidelwein Berlitz", - "email": "eberlitz@gmail.com" - }, - "license": "MIT", - "bugs": { - "url": "https://github.com/eberlitz/splashicon-generator/issues" - }, - "homepage": "https://github.com/eberlitz/splashicon-generator", - "dependencies": { - "colors": "^0.6.2", - "imagemagick": "^0.1.3", - "node-fs": "^0.1.7", - "q": "^1.0.1", - "underscore": "^1.6.0", - "yargs": "^3.8.0" - }, - "contributors": [ - { - "name": "Luiz Pereira de Souza Filho", - "email": "lpsouza@gmail.com" - } - ] -} \ No newline at end of file + "name": "splashicon-generator", + "version": "0.2.12", + "description": "Automatic icon & splash resizing for PhoneGap", + "main": "index.js", + "preferGlobal": false, + "bin": { + "splashicon-generator": "./bin/splashicon-generator" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git://github.com/eberlitz/splashicon-generator.git" + }, + "keywords": [ + "cordova", + "phonegap", + "icon", + "splash", + "resize" + ], + "author": { + "name": "Eduardo Eidelwein Berlitz", + "email": "eberlitz@gmail.com" + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/eberlitz/splashicon-generator/issues" + }, + "homepage": "https://github.com/eberlitz/splashicon-generator", + "dependencies": { + "colors": "^0.6.2", + "gm": "^1.23.0", + "node-fs": "^0.1.7", + "q": "^1.0.1", + "underscore": "^1.6.0", + "yargs": "^3.8.0" + }, + "contributors": [ + { + "name": "Luiz Pereira de Souza Filho", + "email": "lpsouza@gmail.com" + } + ] +}