Skip to content

Commit

Permalink
Merge pull request #527 from Sebmaster/fix/thumbnail-option
Browse files Browse the repository at this point in the history
Make thumbnail accept the same options as resize
  • Loading branch information
aheckmann authored Aug 1, 2016
2 parents 4b7e733 + d7cf98b commit 13b4226
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <width>x<options>, ImageMagick requires <width><options>
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
Expand Down

0 comments on commit 13b4226

Please sign in to comment.