未处理的拒绝错误:无法执行GraphicsMagick / ImageMagick:gm“ identify”“ -ping”“ -format”“%p”“ /tmp/temp.pdf”这很可能意味着gm / convert二进制文件无法执行被发现
我已经尝试了类似问题中提到的所有内容。这是我的第一个lambda函数,被困住了。请在下面找到我如何在我的lambda函数index.js中添加gm
// dependencies
var AWS = require('aws-sdk');
var simpleParser = require('mailparser').simpleParser;
const gm = require('gm').subclass({ imageMagick : true});
var fs = require("fs");
let PDF2Pic = require('pdf2pic').default
let converter = new PDF2Pic({
density: 100, // output pixels per inch
savename: "/tmp/temp", // output file location
format: "jpg" // output size in pixels
});
// by default the first page of the pdf will be converted
// to image
converter.convert("/tmp/temp.pdf")
.then(resolve => {
console.log("image converted successfully")
var contents = fs.readFileSync('/tmp/temp.jpg', 'utf8');
console.log(contents);
});
执行此操作将导致错误:
converter.convert