|
|
|
@ -40,11 +40,11 @@ module.exports = function (proto) { |
|
|
|
|
* @param {Function} callback |
|
|
|
|
* @return {Object} gm |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
proto.write = function write (name, callback) { |
|
|
|
|
if (!callback) callback = name, name = null; |
|
|
|
|
|
|
|
|
|
if (typeof callback !== "function") { |
|
|
|
|
if ("function" !== typeof callback) { |
|
|
|
|
throw new TypeError("gm().write() expects a callback function") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -65,13 +65,13 @@ module.exports = function (proto) { |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
proto.stream = function stream (format, callback) { |
|
|
|
|
if(!callback) callback = format, format = null; |
|
|
|
|
if (!callback) callback = format, format = null; |
|
|
|
|
|
|
|
|
|
if (typeof callback !== "function") { |
|
|
|
|
if ("function" !== typeof callback) { |
|
|
|
|
throw new TypeError("gm().stream() expects a callback function") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(format) { |
|
|
|
|
if (format) { |
|
|
|
|
format = format.split('.').slice(-1)[0].toUpperCase(); |
|
|
|
|
this.outname = format + ":-"; |
|
|
|
|
} |
|
|
|
@ -110,9 +110,9 @@ module.exports = function (proto) { |
|
|
|
|
, err; |
|
|
|
|
|
|
|
|
|
// pipe in the sourceStream if present
|
|
|
|
|
if(self.sourceStream) { |
|
|
|
|
if (self.sourceStream) { |
|
|
|
|
|
|
|
|
|
if(!self.sourceStream.readable && !self.bufferStream) { |
|
|
|
|
if (!self.sourceStream.readable && !self.bufferStream) { |
|
|
|
|
err = new Error("gm().stream() or gm().write() with a non-readable " + |
|
|
|
|
"stream. Pass \"{bufferStream: true}\" to identify() " + |
|
|
|
|
"or getter (size, format, etc...)"); |
|
|
|
@ -122,19 +122,19 @@ module.exports = function (proto) { |
|
|
|
|
self.sourceStream.pipe(proc.stdin); |
|
|
|
|
|
|
|
|
|
// resume any buffered events from a previous identify operation
|
|
|
|
|
if(self.buffer) { |
|
|
|
|
if (self.buffer) { |
|
|
|
|
self.buffer.resume(); |
|
|
|
|
|
|
|
|
|
// if {bufferStream: true} was passed to an identify operation,
|
|
|
|
|
// we buffer the input stream events so we can use them again
|
|
|
|
|
} else if(self.bufferStream) { |
|
|
|
|
} else if (self.bufferStream) { |
|
|
|
|
self.buffer = utils.buffer(self.sourceStream); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// for _exec operations (identify() mostly), we also
|
|
|
|
|
// need to buffer the output stream before returning
|
|
|
|
|
if(bufferOutput) { |
|
|
|
|
if (bufferOutput) { |
|
|
|
|
var stdout = '' |
|
|
|
|
, stderr = ''; |
|
|
|
|
|
|
|
|
@ -164,14 +164,14 @@ module.exports = function (proto) { |
|
|
|
|
|
|
|
|
|
proto.args = function args () { |
|
|
|
|
var source = (this.sourceStream ? "-" : this.source); |
|
|
|
|
if(source && this.sourceFrames) source += this.sourceFrames; |
|
|
|
|
if (source && this.sourceFrames) source += this.sourceFrames; |
|
|
|
|
return [].concat( |
|
|
|
|
'convert' |
|
|
|
|
, this._in |
|
|
|
|
, source |
|
|
|
|
, this._out |
|
|
|
|
, this.outname || "-" |
|
|
|
|
).filter(function(arg) { return !!arg }); |
|
|
|
|
).filter(Boolean); // remove falsey
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|