diff --git a/.gitignore b/.gitignore index 0d04d004..37f3f960 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,6 @@ examples/imgs/* !examples/imgs/photo.JPG !examples/imgs/orientation/*\d.jpg !examples/imgs/orientation/*.correct.jpg +!examples/imgs/icon.ico *.sw* .idea \ No newline at end of file diff --git a/examples/imgs/icon.ico b/examples/imgs/icon.ico new file mode 100644 index 00000000..200367ac Binary files /dev/null and b/examples/imgs/icon.ico differ diff --git a/index.js b/index.js index 6e622d8a..fb86a5e3 100644 --- a/index.js +++ b/index.js @@ -74,6 +74,7 @@ function gm (source, height, color) { var inputFromStdin = this.sourceStream || this.sourceBuffer; var ret = inputFromStdin ? '-' : this.source; + if (inputFromStdin && this.source && this.source !== 'unknown.jpg') ret = this.source.split('.').pop() + ':-'; if (ret && this.sourceFrames) ret += this.sourceFrames; src.length = 0; diff --git a/lib/command.js b/lib/command.js index 9811f739..1d35a540 100644 --- a/lib/command.js +++ b/lib/command.js @@ -224,7 +224,11 @@ module.exports = function (proto) { } catch (e) { return cb(e); } - proc.stdin.once('error', cb); + proc.stdin.on('error', function (err) { + if (err.code !== 'ECONNRESET') { + cb(err); + } + }); if (timeout) { timeoutId = setTimeout(function(){ diff --git a/test/formatInference.js b/test/formatInference.js new file mode 100644 index 00000000..111c5df3 --- /dev/null +++ b/test/formatInference.js @@ -0,0 +1,21 @@ +var assert = require('assert') +var fs = require('fs'); + +module.exports = function (_, dir, finish, gm) { + var m = gm(fs.createReadStream(dir + '/icon.ico'), 'icon.ico') + + var args = m.args(); + assert.equal('convert', args[0]); + assert.equal('ico:-', args[1]); + + if (!gm.integration) + return finish(); + + m + .size({bufferStream: true}, function (err, size) { + if (err) return finish(err); + assert.equal(128, size.width); + assert.equal(128, size.height); + finish(); + }); +} diff --git a/test/gifFrameStream.js b/test/gifFrameStream.js index 5e1d9122..a0bc6d21 100644 --- a/test/gifFrameStream.js +++ b/test/gifFrameStream.js @@ -7,7 +7,7 @@ module.exports = function (_, dir, finish, gm) { var args = m.args(); assert.equal('convert', args[0]); - assert.equal('-[0]', args[1]); + assert.equal('gif:-[0]', args[1]); if (!gm.integration) return finish(); diff --git a/test/resizeAndAutoOrientFromBuffer.js b/test/resizeAndAutoOrientFromBuffer.js index 522bdf98..9ece7727 100755 --- a/test/resizeAndAutoOrientFromBuffer.js +++ b/test/resizeAndAutoOrientFromBuffer.js @@ -14,7 +14,7 @@ module.exports = function (_, dir, finish, gm) { var args = m.args(); assert.equal('convert', args[0]); - assert.equal('-', args[1]); + assert.equal('jpg:-', args[1]); assert.equal('-resize', args[2]); if (m._options.imageMagick) { assert.equal('20%', args[3]); diff --git a/test/resizeBuffer.js b/test/resizeBuffer.js index 208e91a5..0e5c089b 100755 --- a/test/resizeBuffer.js +++ b/test/resizeBuffer.js @@ -13,7 +13,7 @@ module.exports = function (_, dir, finish, gm) { var args = m.args(); assert.equal('convert', args[0]); - assert.equal('-', args[1]); + assert.equal('jpg:-', args[1]); assert.equal('-resize', args[2]); if (m._options.imageMagick) { assert.equal('48%', args[3]); diff --git a/test/streamerr.js b/test/streamerr.js index d9f6c23d..099006e4 100644 --- a/test/streamerr.js +++ b/test/streamerr.js @@ -7,8 +7,7 @@ module.exports = function (_, dir, finish, gm) { // The following invocation should fail, because 'convert' // has no way of interpreting the file. gm( - svg_file, - './test.svg' // fiction + svg_file ).options({ imageMagick: true }).setFormat('png').toBuffer(function(err, buffer) {