diff --git a/index.js b/index.js index 30d3497..24f1bc5 100644 --- a/index.js +++ b/index.js @@ -75,8 +75,11 @@ function gm (source, height, color) { var ret = inputFromStdin ? '-' : this.source; const fileNameProvied = typeof height === 'string'; - if (inputFromStdin && fileNameProvied && /\.ico$/i.test(this.source)) { - ret = `ico:-`; + if (inputFromStdin && fileNameProvied) { + const extensionMatch = this.source.match(/\.(avi|apng|avif|bmp|cgm|dcm|epdf|epi|eps2?|eps3|epsf|ept|fax|fpx|g3|gif87?|ico|jpe?g|mng|mpeg|png|pdf|ps2?|ps3|svg|tiff?|wbmp|webp)$/i); + if (extensionMatch) { + ret = `${extensionMatch[1].toLowerCase()}:-`; + } } if (ret && this.sourceFrames) ret += this.sourceFrames; diff --git a/test/fixtures/test.pdf b/test/fixtures/test.pdf new file mode 100644 index 0000000..982f6ea Binary files /dev/null and b/test/fixtures/test.pdf differ diff --git a/test/pdf.js b/test/pdf.js new file mode 100644 index 0000000..a2c84ec --- /dev/null +++ b/test/pdf.js @@ -0,0 +1,15 @@ +const assert = require('assert'); +const path = require('path'); +const fs = require('fs') + +module.exports = function (_, dir, finish, gm, imageMagick) { + if (!gm.integration) return finish(); + + var imagePath = path.join(__dirname, 'fixtures', 'test.pdf'); + var inputStream = fs.createReadStream(imagePath); + gm(inputStream, 'test.pdf').options({ imageMagick }).identify('%w %h', function(err, value) { + if (err) return finish(err); + assert.equal(value, '612 792'); + finish(); + }); +} diff --git a/test/resizeAndAutoOrientFromBuffer.js b/test/resizeAndAutoOrientFromBuffer.js index c388d12..ab58744 100755 --- a/test/resizeAndAutoOrientFromBuffer.js +++ b/test/resizeAndAutoOrientFromBuffer.js @@ -9,7 +9,7 @@ module.exports = function (_, dir, finish, gm, imageMagick) { var buf = fs.readFileSync(original); - var m = gm(buf, 'resizefrombuffer.jpg') + var m = gm(buf) .options({imageMagick}) .autoOrient() .resize('20%') diff --git a/test/resizeBuffer.js b/test/resizeBuffer.js index e021daf..3e62526 100755 --- a/test/resizeBuffer.js +++ b/test/resizeBuffer.js @@ -15,7 +15,7 @@ module.exports = function (_, dir, finish, gm, imageMagick) { 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]);