Permalink
Browse files

added; geometry support to -scale

relates to #98
  • Loading branch information...
1 parent 3d7a59c commit de52b30741f09353aeca1f7c4cc8d2246ddcddfb @aheckmann committed Dec 14, 2012
Showing with 30 additions and 2 deletions.
  1. +12 −2 lib/args.js
  2. +18 −0 test/scale.js
View
@@ -691,8 +691,18 @@ module.exports = function (proto) {
}
// http://www.graphicsmagick.org/GraphicsMagick.html#details-scale
- proto.scale = function scale (w, h) {
- return this.out("-scale", w +"x"+ h);
+ proto.scale = function scale (w, h, options) {
+ options = options || "";
+ var geometry;
+ if (w && h) {
+ geometry = w + "x" + h + options
+ } else if (w && !h) {
+ geometry = w + options
+ } else if (!w && h) {
+ geometry = 'x' + h + options
+ }
+
+ return this.out("-scale", geometry);
}
// http://www.graphicsmagick.org/GraphicsMagick.html#details-filter
View
@@ -3,6 +3,24 @@ var assert = require('assert')
module.exports = function (gm, dir, finish, GM) {
+ var a = GM('img.png').scale(100);
+ var args = a.args();
+ assert.equal('convert', args[0]);
+ assert.equal('-scale', args[2]);
+ assert.equal('100', args[3]);
+
+ var a = GM('img.png').scale(100, 200, '%');
+ var args = a.args();
+ assert.equal('convert', args[0]);
+ assert.equal('-scale', args[2]);
+ assert.equal('100x200%', args[3]);
+
+ var a = GM('img.png').scale(100, '200%');
+ var args = a.args();
+ assert.equal('convert', args[0]);
+ assert.equal('-scale', args[2]);
+ assert.equal('100x200%', args[3]);
+
var m = gm
.scale(100, 100);

0 comments on commit de52b30

Please sign in to comment.