Reputation: 91
I am trying to create a thumb from a pdf file in a lambda, but when I create the image I get the following error:
Error: stream throws an empty buffer.
I have already increased to 300mb of lambda memory and it doesn't work.
const gm = require("gm").subClass({ imageMagick: true });
const fs = require("fs");
const params = {
Bucket: sourceBucket,
Key: originalNameImg,
};
const pdf = await s3.getObject(params).promise();
temp_file = mktemp.createFileSync(`/tmp/XXXXXX.pdf`);
fs.writeFileSync(temp_file, pdf.Body);
image = gm(temp_file + "[0]");
image.resize("400", "400").toBuffer("jpg", function(err, buffer) {
if (err) {
reject(err);
return;
} else {
resolve();
}
});
The nodejs version I am using is: Node.js 14.x
Upvotes: 2
Views: 352
Reputation: 21
you should install gm package that convert images in AWS AMI.
In latest AWI doesn't have the package.
use AWS layer
Upvotes: 0