From 03d1f4a60db8d28d4c9839120fbaafce77405a99 Mon Sep 17 00:00:00 2001 From: Adam Snodgrass Date: Sat, 7 Sep 2013 16:39:33 -0500 Subject: [PATCH] Added the ability to morph more than two images Forgot to replace undefined variable Removed extra space and added test Swapped monochrome.png with original.png, it doesn't exist before running tests Use Array.isArray() instead of instanceof Array Update morph-more.js Removed todo comment --- lib/convenience/morph.js | 9 ++++++++- test/morph-more.js | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/morph-more.js diff --git a/lib/convenience/morph.js b/lib/convenience/morph.js index cea19da..91b2be9 100644 --- a/lib/convenience/morph.js +++ b/lib/convenience/morph.js @@ -28,7 +28,14 @@ module.exports = function (proto) { var self = this; - self.out(other, "-morph", 1); + if (Array.isArray(other)) { + other.forEach(function (img) { + self.out(img); + }); + self.out("-morph", other.length); + } else { + self.out(other, "-morph", 1); + } self.write(outname, function (err, stdout, stderr, cmd) { if (err) return callback(err, stdout, stderr, cmd); diff --git a/test/morph-more.js b/test/morph-more.js new file mode 100644 index 0000000..fdbd851 --- /dev/null +++ b/test/morph-more.js @@ -0,0 +1,14 @@ +var assert = require('assert') + +module.exports = function (gm, dir, finish, GM) { + + if (gm._options.imageMagick) return finish(); + + if (!GM.integration) + return finish(); + + gm + .morph([dir + '/morpher.jpg', dir + '/original.png'], dir + '/morphed2.jpg', function morph (err) { + finish(err); + }); +}