diff --git a/lib/args.js b/lib/args.js index 5bffdd2f..35089f77 100644 --- a/lib/args.js +++ b/lib/args.js @@ -589,8 +589,25 @@ module.exports = function (proto) { } // http://www.graphicsmagick.org/GraphicsMagick.html#details-thumbnail - proto.thumbnail = function thumbnail (width, height) { - return this.out("-thumbnail", width + "x" + height); + proto.thumbnail = function thumbnail (w, h, options) { + options = options || ""; + var geometry, + wIsValid = Boolean(w || w === 0), + hIsValid = Boolean(h || h === 0); + + if (wIsValid && hIsValid) { + geometry = w + "x" + h + options + } else if (wIsValid) { + // GraphicsMagick requires x, ImageMagick requires + geometry = (this._options.imageMagick) ? w + options : w + + 'x' + options; + } else if (hIsValid) { + geometry = 'x' + h + options + } else { + return this + } + + return this.out("-thumbnail", geometry); } // http://www.graphicsmagick.org/GraphicsMagick.html#details-tile