This is my first lambda function on AWS.
I just want to convert a JPG on S3 to a PNG. So far I've got this:
'use strict';
let aws = require('aws-sdk');
let im = require('imagemagick');
let s3 = new aws.S3();
exports.handler = (event, context, callback) => {
const bucket = event.Records[0].s3.bucket.name;
const key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, ' '));
const s3params = {
Bucket: bucket,
Key: key
};
s3.getObject(s3params, function(err,s3obj) {
//s3obj has the image in .Body...
});
}
I've been trying to find out how to use imagemagick to convert this JPG to a PNG. The convert function seems to require files not buffers. I can't work out how to do it and there doesn't seem like an examples I can find.
Help!