A somewhat updated fork from GraphicsMagick for node
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

41 lines
889 B

var assert = require('assert')
var fs = require('fs');
module.exports = function (gm, dir, finish, GM) {
/*
assert.throws(function () {
gm.stream()
}, /expects a callback/);
assert.throws(function () {
gm.stream('PNG')
}, /expects a callback/);
*/
if (!GM.integration)
return finish();
withCallback(function (err) {
if (err) return finish(err);
withoutCallback(finish);
});
function withCallback(done) {
gm
.stream('PNG', function streamOut (err, stdout, stderr) {
if (err) return done(err);
stdout.pipe(fs.createWriteStream(dir + '/streamOut.png'));
stdout.on('error', done);
stdout.on('close', done);
});
}
function withoutCallback(done) {
var stream = gm.stream('PNG')
stream.on('error', done)
stream.pipe(fs.createWriteStream(dir + '/streamOut2.png'))
stream.on('end', done)
}
}