user3830714
user3830714

Reputation: 91

AWS lambda Converting inbound PDF to JPGS

Currently i am doing a simple copy with a lambda function in node.js where i copy an incoming pdf file to another bucket.
What i would like to do is copy that PDF and create a jpg of each page. i currently have a back end process doing this with imagemagick but would like to move it into my lambda function maybe with using gm?

Here is my current code.

var params = {
    CopySource: srcBucket + '/' + srcKey,
    Bucket: destinationbucket,
    Key: outfile.pdf
};

s3.copyObject(params, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
    context.succeed('exit');
});

Upvotes: 0

Views: 1054

Answers (1)

Mark B
Mark B

Reputation: 200456

ImageMagic is available for NodeJS Lambda functions. From the documentation:

If you author your Lambda function code in Node.js, the following libraries are available in the AWS Lambda execution environment so you don't need to include them:

ImageMagick: Installed with default settings. For versioning information, see imagemagick nodejs wrapper and ImageMagick native binary (search for "ImageMagick").

So you should be able to move your current solution to Lambda fairly easily.

Upvotes: 1

Related Questions