|
|
|
@ -95,6 +95,10 @@ module.exports = function (gm) { |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
proto.identify = function identify (opts, callback) { |
|
|
|
|
// identify with pattern
|
|
|
|
|
if (typeof(opts) === 'string') { |
|
|
|
|
return identifyPattern.apply(this, arguments); |
|
|
|
|
} |
|
|
|
|
if (!callback) callback = opts, opts = {}; |
|
|
|
|
if (!callback) return this; |
|
|
|
|
|
|
|
|
@ -139,6 +143,34 @@ module.exports = function (gm) { |
|
|
|
|
return self; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* identify with pattern |
|
|
|
|
* |
|
|
|
|
* Execute `identify -format` with custom pattern |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
function identifyPattern (pattern, opts, callback) { |
|
|
|
|
if (!callback) callback = opts, opts = {}; |
|
|
|
|
if (!callback) return this; |
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
|
|
self.bufferStream = !!opts.bufferStream; |
|
|
|
|
|
|
|
|
|
var args = makeArgs(self, { format: pattern }); |
|
|
|
|
self._exec(args, function (err, stdout, stderr, cmd) { |
|
|
|
|
if (err) { |
|
|
|
|
return callback.call(self, err, undefined, stdout, stderr, cmd); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
callback.call(self, err, (stdout||'').trim()); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return self; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Parses `identify` responses. |
|
|
|
|
* |
|
|
|
|