Comparing version 1.22.0 to 1.23.0
1.23.0 / 2016-08-03 | ||
* fixed; webpack support #547 sean-shirazi | ||
* fixed; windows support - use cross-spawn to spawn processes #537 bdukes | ||
* added; allow thumbnail to accept the same options as resize #527 Sebmaster | ||
* added; dispose support #487 dlwr | ||
* docs; add example of loading image from URL #544 wahengchang | ||
* docs; Fix a link in README.md #532 clbn | ||
* travis; update travis versions #551 amilajack | ||
1.22.0 / 2016-04-07 | ||
@@ -3,0 +13,0 @@ |
@@ -129,5 +129,2 @@ | ||
module.exports.compare = require('./lib/compare')(); | ||
module.exports.version = JSON.parse( | ||
require('fs').readFileSync(__dirname + '/package.json', 'utf8') | ||
).version; | ||
module.exports.version = require('./package.json').version; |
@@ -592,4 +592,21 @@ /** | ||
// http://www.graphicsmagick.org/GraphicsMagick.html#details-thumbnail | ||
proto.thumbnail = function thumbnail (width, height) { | ||
return this.out("-thumbnail", width + "x" + height); | ||
proto.thumbnail = function thumbnail (w, h, options) { | ||
options = options || ""; | ||
var geometry, | ||
wIsValid = Boolean(w || w === 0), | ||
hIsValid = Boolean(h || h === 0); | ||
if (wIsValid && hIsValid) { | ||
geometry = w + "x" + h + options | ||
} else if (wIsValid) { | ||
// GraphicsMagick requires <width>x<options>, ImageMagick requires <width><options> | ||
geometry = (this._options.imageMagick) ? w + options : w + | ||
'x' + options; | ||
} else if (hIsValid) { | ||
geometry = 'x' + h + options | ||
} else { | ||
return this | ||
} | ||
return this.out("-thumbnail", geometry); | ||
} | ||
@@ -596,0 +613,0 @@ |
@@ -6,3 +6,3 @@ | ||
var spawn = require('child_process').spawn; | ||
var spawn = require('cross-spawn'); | ||
var utils = require('./utils'); | ||
@@ -215,2 +215,3 @@ var debug = require('debug')('gm'); | ||
, timeout = parseInt(this._options.timeout) | ||
, disposers = this._options.disposers | ||
, timeoutId; | ||
@@ -241,11 +242,14 @@ | ||
timeoutId = setTimeout(function(){ | ||
err = new Error('gm() resulted in a timeout.'); | ||
cb(err); | ||
if (proc.connected) { | ||
proc.stdin.pause(); | ||
proc.kill(); | ||
} | ||
dispose('gm() resulted in a timeout.'); | ||
}, timeout); | ||
} | ||
if (disposers) { | ||
disposers.forEach(function(disposer) { | ||
disposer.events.forEach(function(event) { | ||
disposer.emitter.on(event, dispose); | ||
}); | ||
}); | ||
} | ||
if (self.sourceBuffer) { | ||
@@ -317,8 +321,18 @@ proc.stdin.write(this.sourceBuffer); | ||
cb.called = 1; | ||
if (args[0] !== 'identify' && bin !== 'identify') { | ||
self._in = []; | ||
self._out = []; | ||
} | ||
if (args[0] !== 'identify' && bin !== 'identify') { | ||
self._in = []; | ||
self._out = []; | ||
} | ||
callback.call(self, err, stdout, stderr, cmd); | ||
} | ||
function dispose (msg) { | ||
var message = msg ? msg : 'gm() was disposed'; | ||
err = new Error(message); | ||
cb(err); | ||
if (proc.exitCode === null) { | ||
proc.stdin.pause(); | ||
proc.kill(); | ||
} | ||
} | ||
} | ||
@@ -415,2 +429,23 @@ | ||
} | ||
/** | ||
* add disposer (like 'close' of http.IncomingMessage) in order to dispose gm() with any event | ||
* | ||
* @param {EventEmitter} emitter | ||
* @param {Array} events | ||
* @return {Object} gm | ||
* @example | ||
* command.addDisposer(req, ['close', 'end', 'finish']); | ||
*/ | ||
proto.addDisposer = function addDisposer (emitter, events) { | ||
if (!this._options.disposers) { | ||
this._options.disposers = []; | ||
} | ||
this._options.disposers.push({ | ||
emitter: emitter, | ||
events: events | ||
}); | ||
return this; | ||
}; | ||
} |
// compare | ||
var spawn = require('child_process').spawn; | ||
var spawn = require('cross-spawn'); | ||
@@ -5,0 +5,0 @@ /** |
{ | ||
"name": "gm", | ||
"description": "GraphicsMagick and ImageMagick for node.js", | ||
"version": "1.22.0", | ||
"version": "1.23.0", | ||
"author": "Aaron Heckmann <aaron.heckmann+github@gmail.com>", | ||
@@ -43,6 +43,7 @@ "keywords": [ | ||
"dependencies": { | ||
"debug": "~2.2.0", | ||
"array-parallel": "~0.1.3", | ||
"array-series": "~0.1.5", | ||
"array-parallel": "~0.1.3" | ||
"cross-spawn": "^4.0.0", | ||
"debug": "~2.2.0" | ||
} | ||
} |
@@ -141,2 +141,14 @@ | ||
// passing a downloadable image by url | ||
var request = require('request'); | ||
var url = "www.abc.com/pic.jpg" | ||
gm(request(url)) | ||
.write('/path/to/reformat.png', function (err) { | ||
if (!err) console.log('done'); | ||
}); | ||
// can also stream output to a ReadableStream | ||
@@ -317,3 +329,3 @@ // (can be piped to a local file or remote server) | ||
- [size](http://aheckmann.github.com/gm/docs.html#getters) - returns the size (WxH) of the image | ||
- [orientation](http://aheckmann.github.com/gm/docs.html#orientation) - returns the EXIF orientation of the image | ||
- [orientation](http://aheckmann.github.com/gm/docs.html#getters) - returns the EXIF orientation of the image | ||
- [format](http://aheckmann.github.com/gm/docs.html#getters) - returns the image format (gif, jpeg, png, etc) | ||
@@ -320,0 +332,0 @@ - [depth](http://aheckmann.github.com/gm/docs.html#getters) - returns the image color depth |
Sorry, the diff of this file is not supported yet
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
117805
22
2171
650
1
0
4
+ Addedcross-spawn@^4.0.0
+ Addedcross-spawn@4.0.2(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedyallist@2.1.2(transitive)