|
|
|
@ -15,6 +15,7 @@ var series = require('array-series'); |
|
|
|
|
|
|
|
|
|
var missingIM = '** Have you installed imageMagick? **\n'; |
|
|
|
|
var missingGM = '** Have you installed graphicsmagick? **\n'; |
|
|
|
|
var noBufferConcat = 'gm v1.9.0+ required node v0.8+. Please update your version of node, downgrade gm < 1.9, or do not use `bufferStream`.'; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* End event for child_process |
|
|
|
@ -184,28 +185,27 @@ module.exports = function (proto) { |
|
|
|
|
|
|
|
|
|
self.sourceStream.pipe(proc.stdin); |
|
|
|
|
|
|
|
|
|
// We cache the buffers for get operations
|
|
|
|
|
// as we may use it again.
|
|
|
|
|
// This wouldn't make sense for a convert operation.
|
|
|
|
|
// We rely on garbage collection for optimization,
|
|
|
|
|
// so if want to kill trash the garbage quickly,
|
|
|
|
|
// do `this._buffers = null`.
|
|
|
|
|
// We do this in lieu of `bufferStream`,
|
|
|
|
|
// with this being more magical.
|
|
|
|
|
// bufferStream
|
|
|
|
|
// We convert the input source from a stream to a buffer.
|
|
|
|
|
if (self.bufferStream && !this._buffering) { |
|
|
|
|
if (!Buffer.concat) { |
|
|
|
|
throw new Error(noBufferConcat); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Incase there are multiple processes in parallel,
|
|
|
|
|
// we only need one
|
|
|
|
|
this._buffering = true |
|
|
|
|
var buffers = [] |
|
|
|
|
self._buffering = true; |
|
|
|
|
|
|
|
|
|
var buffers = []; |
|
|
|
|
|
|
|
|
|
self.sourceStream.on('data', function (chunk) { |
|
|
|
|
buffers.push(chunk) |
|
|
|
|
buffers.push(chunk); |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// Kill reference as we assume the stream is dead.
|
|
|
|
|
self.sourceStream.on('end', function () { |
|
|
|
|
self.sourceBuffer = Buffer.concat(buffers) |
|
|
|
|
self.sourceStream = null |
|
|
|
|
self.sourceBuffer = Buffer.concat(buffers); |
|
|
|
|
// Kill reference as we assume the stream is dead.
|
|
|
|
|
self.sourceStream = null; |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|