Comparing version 1.10.0 to 1.11.0
@@ -0,1 +1,7 @@ | ||
1.11.0 / 2013-07-23 | ||
=================== | ||
* added; optional formatting string for gm().identify(format, callback) | ||
* removed; error messages when gm/im binary is not installed | ||
1.10.0 / 2013-06-27 | ||
@@ -2,0 +8,0 @@ =================== |
@@ -18,4 +18,2 @@ | ||
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`.'; | ||
@@ -189,14 +187,2 @@ | ||
if (self.sourceBuffer || self.sourceStream) { | ||
// handle streaming errors when gm/imageMagick is not installed | ||
proc.stdin.on('error', handlerr); | ||
proc.stdout.on('error', handlerr); | ||
function handlerr (err) { | ||
if ('EPIPE' == err.code && 'write' == err.syscall) { | ||
err.message = missingBinMsg(self) + err.message; | ||
} | ||
cb(self, err); | ||
} | ||
} | ||
if (self.sourceBuffer) { | ||
@@ -209,3 +195,3 @@ proc.stdin.write(this.sourceBuffer); | ||
err = new Error("gm().stream() or gm().write() with a non-readable stream."); | ||
return cb(self, err); | ||
return cb(err); | ||
} | ||
@@ -252,4 +238,2 @@ | ||
if (code !== 0 || signal !== null) { | ||
if (127 == code) | ||
stderr += missingBinMsg(self); | ||
err = new Error('Command failed: ' + stderr); | ||
@@ -259,7 +243,9 @@ err.code = code; | ||
}; | ||
cb(self, err, stdout, stderr, cmd); | ||
cb(err, stdout, stderr, cmd); | ||
stdout = stderr = onOut = onErr = onExit = null; | ||
}); | ||
proc.on('error', cb); | ||
} else { | ||
cb(self, null, proc.stdout, proc.stderr, cmd); | ||
cb(null, proc.stdout, proc.stderr, cmd); | ||
} | ||
@@ -269,3 +255,3 @@ | ||
function cb (self, err, stdout, stderr, cmd) { | ||
function cb (err, stdout, stderr, cmd) { | ||
if (cb.called) return; | ||
@@ -281,7 +267,2 @@ cb.called = 1; | ||
function missingBinMsg (self) { | ||
if (self._options.imageMagick) return missingIM; | ||
return missingGM; | ||
} | ||
/** | ||
@@ -288,0 +269,0 @@ * Returns arguments to be used in the command. |
@@ -98,4 +98,11 @@ /** | ||
proto.identify = function identify (opts, callback) { | ||
// identify with pattern | ||
if (typeof(opts) === 'string') { | ||
opts = { | ||
format: opts | ||
} | ||
} | ||
if (!callback) callback = opts, opts = {}; | ||
if (!callback) return this; | ||
if (opts && opts.format) return identifyPattern.call(this, opts, callback); | ||
@@ -143,3 +150,28 @@ var self = this; | ||
/** | ||
* identify with pattern | ||
* | ||
* Execute `identify -format` with custom pattern | ||
*/ | ||
function identifyPattern (opts, callback) { | ||
var self = this; | ||
self.bufferStream = !!opts.bufferStream; | ||
var args = makeArgs(self, opts); | ||
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. | ||
@@ -146,0 +178,0 @@ * |
{ "name": "gm" | ||
, "description": "GraphicsMagick for node.js" | ||
, "version": "1.10.0" | ||
, "version": "1.11.0" | ||
, "author": "Aaron Heckmann <aaron.heckmann+github@gmail.com>" | ||
@@ -5,0 +5,0 @@ , "keywords": ["graphics", "magick", "image", "graphicsmagick", "imagemagick", "gm", "convert", "identify", "compare"] |
@@ -1,2 +0,2 @@ | ||
# gm v1.10.0 [](https://travis-ci.org/aheckmann/gm) | ||
# gm v1.11.0 [](https://travis-ci.org/aheckmann/gm) | ||
@@ -207,2 +207,22 @@ GraphicsMagick for node | ||
### Custom Identify Format String | ||
When identifying an image, you may want to use a custom formatting string instead of using `-verbose`, which is quite slow. | ||
You can use your own [formatting string](http://www.imagemagick.org/script/escape.php) when using `gm().identify(format, callback)`. | ||
For example, | ||
```js | ||
gm('img.png').format(function (err, format) { | ||
}) | ||
// is equivalent to | ||
gm('img.png').identify('%m', function (err, format) { | ||
}) | ||
``` | ||
since `%m` is the format option for getting the image file format. | ||
which correctly yields: | ||
@@ -260,3 +280,3 @@ | ||
- [filesize](http://aheckmann.github.com/gm/docs.html#getters) - returns image filesize | ||
- [identify](http://aheckmann.github.com/gm/docs.html#getters) - returns all image data available | ||
- [identify](http://aheckmann.github.com/gm/docs.html#getters) - returns all image data available. Takes an optional format string. | ||
@@ -263,0 +283,0 @@ - manipulation |
97915
1829
543