diff --git a/History.md b/History.md index d71ac0f..0c27dd5 100644 --- a/History.md +++ b/History.md @@ -1,15 +1,16 @@ -1.9.2 +1.9.2 / 2013-06-12 ================== * refactor; move `streamToBuffer` to a separate module + * fixed; .stream(format) without a callback -1.9.1 / 2012-05-07 +1.9.1 / 2013-05-07 ================== * fixed; gm().resize(width) always only resizes width * fixed; gm('img.gif').format() returns the format of the first frame -1.9.0 / 2012-04-21 +1.9.0 / 2013-04-21 ================== * added; node v0.10 support diff --git a/lib/command.js b/lib/command.js index a2ca64a..0c15225 100644 --- a/lib/command.js +++ b/lib/command.js @@ -86,7 +86,10 @@ module.exports = function (proto) { */ proto.stream = function stream (format, callback) { - if (!callback) callback = format, format = null; + if (!callback && typeof format === 'function') { + callback = format; + format = null; + } var throughStream; diff --git a/test/streamOutFormat.js b/test/streamOutFormat.js index f2200f5..4924d26 100644 --- a/test/streamOutFormat.js +++ b/test/streamOutFormat.js @@ -19,7 +19,11 @@ module.exports = function (gm, dir, finish, GM) { withCallback(function (err) { if (err) return finish(err); - withoutCallback(finish); + withoutCallback(function (err) { + if (err) return finish(err); + + checkOutputFormat(finish); + }); }); function withCallback(done) { @@ -38,4 +42,16 @@ module.exports = function (gm, dir, finish, GM) { stream.pipe(fs.createWriteStream(dir + '/streamOut2.png')) stream.on('end', done) } + + function checkOutputFormat(done) { + var stream = gm.stream('PNG') + stream.on('error', done) + GM(stream).format(function (err, value) { + if (err) + return done(err) + + assert.equal(value.toLowerCase(), 'png') + done() + }) + } }