Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Binary file added test/fixtures/test.pdf
Binary file not shown.
15 changes: 15 additions & 0 deletions test/pdf.js
Original file line number Diff line number Diff line change
@@ -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();
});
}
2 changes: 1 addition & 1 deletion test/resizeAndAutoOrientFromBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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%')
Expand Down
2 changes: 1 addition & 1 deletion test/resizeBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down