fixed; .stream(format) without a callback

master
Jonathan Ong 11 years ago
parent c2c82f66e9
commit 0d7f7d8e0b
  1. 7
      History.md
  2. 5
      lib/command.js
  3. 18
      test/streamOutFormat.js

@ -1,15 +1,16 @@
1.9.2 1.9.2 / 2013-06-12
================== ==================
* refactor; move `streamToBuffer` to a separate module * 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().resize(width) always only resizes width
* fixed; gm('img.gif').format() returns the format of the first frame * 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 * added; node v0.10 support

@ -86,7 +86,10 @@ module.exports = function (proto) {
*/ */
proto.stream = function stream (format, callback) { proto.stream = function stream (format, callback) {
if (!callback) callback = format, format = null; if (!callback && typeof format === 'function') {
callback = format;
format = null;
}
var throughStream; var throughStream;

@ -19,7 +19,11 @@ module.exports = function (gm, dir, finish, GM) {
withCallback(function (err) { withCallback(function (err) {
if (err) return finish(err); if (err) return finish(err);
withoutCallback(finish); withoutCallback(function (err) {
if (err) return finish(err);
checkOutputFormat(finish);
});
}); });
function withCallback(done) { function withCallback(done) {
@ -38,4 +42,16 @@ module.exports = function (gm, dir, finish, GM) {
stream.pipe(fs.createWriteStream(dir + '/streamOut2.png')) stream.pipe(fs.createWriteStream(dir + '/streamOut2.png'))
stream.on('end', done) 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()
})
}
} }

Loading…
Cancel
Save