Permalink
Browse files

Add support for thumbnail

  • Loading branch information...
1 parent e51540d commit 03eebf464b92f76db1b86b968b1b33184b510581 @danmilon danmilon committed Nov 7, 2012
Showing with 24 additions and 0 deletions.
  1. +10 −0 examples/thumbnail.js
  2. +5 −0 lib/args.js
  3. +9 −0 test/thumbnail.js
View
@@ -0,0 +1,10 @@
+var gm = require('../')
+ , dir = __dirname + '/imgs'
+
+gm(dir + '/original.jpg')
+ .thumbnail(150, 150)
+ .write(dir + '/thumbnail.jpg', function(err){
+ if (err) return console.dir(arguments)
+ console.log(this.outname + " created :: " + arguments[3])
+ }
+)
View
@@ -564,6 +564,11 @@ module.exports = function (proto) {
return this.out("-threshold", value+(percent?'%':''));
}
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-thumbnail
+ proto.thumbnail = function thumbnail (width, height) {
+ return this.out("-thumbnail", width + "x" + height);
+ }
+
// http://www.graphicsmagick.org/GraphicsMagick.html#details-tile
proto.tile = function tile (filename) {
return this.out("-tile", filename);
View
@@ -0,0 +1,9 @@
+
+module.exports = function (gm, dir, finish) {
+
+ gm
+ .thumbnail(200, 200)
+ .write(dir + '/thumbnail.png', function thumbnail (err) {
+ finish(err);
+ });
+}

0 comments on commit 03eebf4

Please sign in to comment.